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?
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
Post a Comment