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

round image using picasso in android -

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

python - How to remove the Xframe Options header in django? -