I am loading HTML string in UIWebView. In that screen, when user selects particular text, I show option to save that string and store that string somewhere. Now, the next time user loads same page, the text which was saved by user, should be automatically highlighted. How would I achieve this?
Asked
Active
Viewed 2,139 times
0
-
possible duplicate of [Programmatically select text in UIWebView](http://stackoverflow.com/questions/13491485/programmatically-select-text-in-uiwebview) – fpg1503 Feb 18 '15 at 12:34
1 Answers
1
I think you could manipulate the website via javascript
. Just save the string to highlight and the corresponding site.
When the user enters the page again have a look if you already have a highlighted string for this site & user. If yes you can manipulate the site via:
[webview stringByEvaluatingJavaScriptFromString:jsCode];
Here is a jsfiddle for example to highlight text via javascript:demo
EDIT A useful collection of answers concerning how to select specific text on a website via javascript can also be found here: Highlighting text using javascript