Skip to content Skip to sidebar Skip to footer

Uiwebview Javascript Injection

I've been looking at enough blogs so I'm pretty sure how it's coded... but none of them seem to mention where the javascript injection goes in the Obj-C code? Basically all I want

Solution 1:

Your javascript code should be executed one your whole HTML document has been loaded (and all its DOM objects).

Thus you should paste your stringByEvaluatingJavascriptFromString call in the UIWebView's delegate method - (void)webViewDidFinishLoad:(UIWebView *)webView (of course you need to implement this code in an object that will be set as the delegate of the UIWebView, as for any delegate method and for every time you use the delegate pattern)

Post a Comment for "Uiwebview Javascript Injection"