Running JavaScript in a WebView?

I’ve looked around, and tried a bunch of different things, but I can’t seem to run JavaScript code in a web view!

And by that I mean custom-defined JavaScript, not JavaScript run on the page.

For example, typing:

…into Safari’s window will, indeed run the JavaScript code. Is there any way to simulate the same thing in a web view?

If so, how?

-SuperScripter

PS I know there was another thread about this, but the solution was to include the JavaScript in the HTML file, which doesn’t help me when I’m loading it from a custom URL.

Here is some Objective-C that I have used in the past.

An example calling the method

Thanks so much!

Could you help me with one more thing, though?

I’m a bit confused (and altogether awful) at converting that ObjC code to AppleScript calls. :confused:

Would someone be kind enough to show me this?

-SuperScripter

I wrote an article on this subject that you can find here