It seems to me that you are not using a delegate in your UIWebView. If you set the delegate and put the Javascript call in the webViewDidFinishLoad: (UIWebView *) webView method, it works fine:
UIWebView *wv = [[UIWebView alloc] initWithFrame:CGRectMake(0.0, 0.0, 700.0, 700.0)]; [self.view addSubview:wv]; wv.delegate = self; [wv loadHTMLString:@"<html><head><script type='text/javascript'>function sample() {alert('Paznja');}</script></head><body><h1>TEST</h1></body></html>" baseURL:nil]; [wv release];
and in the same class:
- (void)webViewDidFinishLoad:(UIWebView *)webView { [webView stringByEvaluatingJavaScriptFromString:@"sample()"]; }
When I run this code, the warning message is working fine.
joern
source share