Code:
<div id="count">
1
<span style="font-size: 15px; ">
<span>
<br id="miobr"/>
<br id="miobr"/>
</span>
</span>
</div>
I need to get the 1 from the html snippet loaded into a webview but the javascript i've tried doesn't seem to work?
Code:
NSString *pms = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsById('count').innerHTML"];
NSString *pms = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsById('count').innerText"];
//This last one is changing the documents title to it (or trying to) as i know i can extract the title quite easily.
[webView stringByEvaluatingJavaScriptFromString:@"var script = document.createElement('script');"
"script.type = 'text/javascript';"
"script.text = \"function myFunction() { "
"var field = document.getElementById('count');"
"document.title = field.InnerText;"
"}\";"
"document.getElementsByTagName('head')[0].appendChild(script);"];
[webView stringByEvaluatingJavaScriptFromString:@"myFunction();"];
NSString *pms = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
Any help with this?
I'm not that good with javascript so that might be my problem but i don't know what would work?