Help with stringByEvaluatingJavaScriptFromString in UIWebView

Joined
Mar 21, 2012
Messages
5
Reaction score
0
Points
1
Location
Eagan, MN
Your Mac's Specs
Aluminum Unibody Macbook (Late 2008) 2.4 GHz Intel Core 2 Duo, 250GB HD, 6GB RAM, 10.8 Dev Preview
Can anyone tell me why the following code isn't working?

- (void)viewDidLoad
{
[super viewDidLoad];

NSString *website = @"http://www.rschooltoday.com/se3bin/clientgenie.cgi?schoolname=school1&statusFlag=goGenie&geniesite=1145&myButton=g5plugin&db=g1145_b16145";
NSURL *url = [NSURL URLWithString:website];
//NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
//[webview loadRequest:requestUrl];
NSString *html = [webview stringByEvaluatingJavaScriptFromString:
@"getElementById(content_well_div_)"];
[self.webview loadHTMLString:html baseURL:url];
}

I'm trying to load just the central content of that teacher's page, but I don't have much experience with JS or HTML, this is just what I've been able to figure out from other forums and Wikipedia. :p

Thanks in advance!!
 
Joined
Aug 13, 2011
Messages
200
Reaction score
7
Points
18
Location
West Sussex
Sorry to say it, but your code is a bit of a mess, firstly you need to use NSURLConnection, NSURLRequest, and NSURL class's to make it possible.

Also I noticed you have commented out two of the above lines of code.

//NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
//[webview loadRequest:requestUrl];

So these two lines are doing nothing.

I would reccommend you read the Apple documentation that deals with loading URL's.

https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/URLLoadingSystem/URLLoadingSystem.html#//apple_ref/doc/uid/10000165i

Try reading this, and things will be a lot clearer for you.

Regards Mark
 
OP
amarkon
Joined
Mar 21, 2012
Messages
5
Reaction score
0
Points
1
Location
Eagan, MN
Your Mac's Specs
Aluminum Unibody Macbook (Late 2008) 2.4 GHz Intel Core 2 Duo, 250GB HD, 6GB RAM, 10.8 Dev Preview
Thanks. I just don't use JS or HTML often, much less WebViews.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top