UIWebView document.getSelection() script returns nothing
I have a UIWebView displaying string containing a locally generated sequence of Korean and Russian words. I.e. there is nothing special in the string, just simple 'body'/'span' tags to format the text.
I need to get selected text, so I use:
NSString *selected = [articleWebView stringByEvaluatingJavaScriptFromString:@"document.getSelection()"];
This returns nothing: NSLog (@"%@", selected);
logs out nothing.
What can be a problem here? I haven't found anyone here having similar problem and it's driving me nuts. Please, 开发者_C百科help.
OK, I've got it. The following works just fine:
NSString *selection = [articleWebView stringByEvaluatingJavaScriptFromString:@"window.getSelection().toString()"];
Use this, not that.
精彩评论