ios - Get word under tap from UIWebView using JavaScript -


i'm displaying local web content , word under tap point. single tap delegate setup , can work great if use uitextview , load html nsattributedstring , nshtmltextdocumenttype, lose formatting such paragraph spacing , small caps; adding nsmutableparagraphstyle without effect.

using uiwebview , loadhtmlstring includes jquery, there way? there several pages show how use js word under cursor, such following:

how word under cursor using javascript?

how word under cursor?

get word under mouse pointer

is possible word under mouse cursor in `<textarea>`? how word under cursor?

but after several days, i've been unable work. code:

var jsfile = nsbundle.mainbundle().pathforresource("webview", oftype: "js"); let jsdata = nsstring(contentsoffile:jsfile!, encoding:nsutf8stringencoding, error:nil) as! string let returned = webview.stringbyevaluatingjavascriptfromstring(jsdata)! string println("returned \(returned).") 

the word unicode different code range, getting word work first wonderful.


Comments

Popular posts from this blog

What Are The Best Universities In The World?

Hard vs. Soft Water: What's The Difference?

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -