Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

tdog09

macrumors member
Original poster
Jul 13, 2008
73
0
Hi All-

So I've been bashing my head in with this the past few days. What I have is a UIWebView that has loaded a webpage, say www.mypage.com.

The html of mypage.com contains javascript that computes certain things for the page to display.

How would I be able to call the javascript functions of this page from objective c, and return those values?

Say the webpage has a function called foo(), that when called spits out the phrase,"foo was called". I would like from object C to be able to call this function, and print what it returns in NSLOG. Is this possible?

Any help is greatly appreciated. Thanks!
 
Read the UIWebview documentation and look up the stringByEvaluatingJavaScriptFromString method.


Thanks but i am working with this, and threw my million tries have yet to get it to work. I do read documentation, and have read tons, but still to no avail.

Thanks!
 
Thanks but i am working with this, and threw my million tries have yet to get it to work. I do read documentation, and have read tons, but still to no avail.

Thanks!

NSLog(@"js result -", [webView stringByEvaluatingJavaScriptFromString:mad:"foo();"]);

works for me.
 
Also try something simple first...make sure that JavaScript is turned on in the device's preferences.

Linda
 
Are you sure you've loaded the entire web page into the UIWebView?

Some devs have forgotten to put all the parts into the app bundle the correct way.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.