views:

633

answers:

1

I have a UIWebView component that is going to load a webpage which might contain JavaScript. I want to run some JavaScript of my own before any JavaScript on the loaded webpage runs. I know I can use [myWebView stringByEvaulatingJavaScriptFromString:] on the webViewDidFinishLoad: delegate of the UIWebView, however this will only run my JavaScript after the JavaScript on the webpage is run.

Is the only solution to inject my JavaScript into the source code of the webpage? For example, I would put it immediately after the <head> tag to insure it is the first JavaScript that is run.

A: 

Check this post about JS execution order. There is another tutorial here for the same issue. If you have a problem with a specific piece of code add it here in a detailed example and will see what it can be done.

Elzo Valugi