Wednesday, 30 July 2014

Highlight Text in UIWebView using JavaScript

[webView stringByEvaluatingJavaScriptFromString:@"var range = window.getSelection().getRangeAt(0);"
    @"var selectionContents = range.extractContents();"
    @"var span = document.createElement('span');"
    @"span.style.backgroundColor = 'yellow';"
    @"span.appendChild(selectionContents);"
    @"range.insertNode(span)" ];

No comments:

Post a Comment