I have the following code in a view controller. "pageDisplay" is a UIWebView.
When I run the app in simulator, the HTML page comes up as it appears before the JS runs. The element with id "myHeader", an <h1>
tag, is unchanged.
-(void) loadPageToView:(int)pageNumber{
NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%d",pageNumber]ofType:@"html"];
NSURL *url = [NSURL fileURLWithPath:path];
NSURLRequest *request = [NSURLRequest requestWithURL:url];
[pageDisplay loadRequest:request];
[self doJavaScript];
}
-(void) doJavaScript{
[pageDisplay stringByEvaluatingJavaScriptFromString:@"document.getElementById('myHeader').innerHTML = \"FOO\";"];
}