UIWebView not evaluating javascript properly
Posted
by jammur
on Stack Overflow
See other posts from Stack Overflow
or by jammur
Published on 2010-06-17T00:25:51Z
Indexed on
2010/06/17
0:32 UTC
Read the original article
Hit count: 253
I'm trying to run some javascript against a UIWebView but it's doesn't seem to be working. For example, here is a snippet of html I'm using to test:
<html><body><h1>Hello World!</h1><p>It's me.</p></body></html>
If I run the following javascript against it, the return value is 0, when it should be 1.
var elements = document.getElementsByTagName("h1");
elements.length;
Here's the objc code I'm using for the webview. 'parser' is a string containing the above javascript:
[webView loadHTMLString:@"<html><body><h1>Hello World!</h1><p>It's me.</p></body></html>" baseURL:nil];
NSString *markupResult = [webView stringByEvaluatingJavaScriptFromString:parser];
© Stack Overflow or respective owner