Hi to everyone this is my first post and I’m really happy that I’ve found this community.
It’s a big help for new ones in ASOC like me.
Here’s my situation.
I have a webView where I open a URL.
I’d like to execute in that webView a javascript to fill a couple of fields to enter in the user’s area of web site.
So how can I execute Javascript in a webView? I tried this:
-- Code to access to mypage in my webView (webViewP)
webViewP's setMainFrameURL_("http://www.mypage.com")
-- Code to execute javascript
webViewP's stringByEvaluatingJavaScriptFromString_("alert('Javascript executed!!');")
No error compiling. No error executing. But no Javascript!
And I don’t understand why … As I said I’m not an expert so maybe the answer to the question is really simple, but any help?
Thank you
Model: MacBook Pro 2.53
Browser: Safari 534.51.22
Operating System: Mac OS X (10.7)
I’ve tried two ways, as instructed by the documentation, and they both did not do anything, but there were no errors. I will try some other JavaScript commands.
After some reading, it looks like the alert function just tells the current browser to display the said text in it’s operating system’s default alert box. So that being said, I guess those user interaction functions don’t work because it’s not wired into The WebView to display a dialog.
Long story short, maybe use Shane’s method to extract text from the site and display it in an alert via AppleScript.