Created
April 17, 2012 00:55
-
-
Save yeahq/2402648 to your computer and use it in GitHub Desktop.
Run Javascript in UIWebView
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// From: http://iphoneincubator.com/blog/windows-views/how-to-inject-javascript-functions-into-a-uiwebview | |
NSString *title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"]; | |
[webView stringByEvaluatingJavaScriptFromString:@"var script = document.createElement('script');" | |
"script.type = 'text/javascript';" | |
"script.text = \"function myFunction() { " | |
"var field = document.getElementById('field_3');" | |
"field.value='Calling function - OK';" | |
"}\";" | |
"document.getElementsByTagName('head')[0].appendChild(script);"]; | |
[webView stringByEvaluatingJavaScriptFromString:@"myFunction();"]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment