如何在UIWebView中检测java脚本

时间:2011-04-15 07:27:20

标签: iphone uiwebview

在网页中,我有两个选择框,在从第一个选择框中选择一个值后,第二个选择框如果由java脚本填充或者可能是Ajex。但是在我的UIWebView中,第二个选择框没有填充。所以请帮帮我。这在Safari浏览器中运行良好。

- (void)viewDidLoad {
    [super viewDidLoad];

    [myWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]]];
}


-(void)webViewDidStartLoad:(UIWebView *) portal {
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES; 
}

-(void)webViewDidFinishLoad:(UIWebView *) portal{
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
}


- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
    NSString *userInfo = [[error userInfo] objectForKey:NSURLErrorFailingURLPeerTrustErrorKey];
    NSLog(@"Connection failed! Error - %@ %@",[error localizedDescription],userInfo);   

    UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:[error localizedDescription] message:userInfo delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil,nil];
    [alerView show];
    [alerView release]; 
    [UIApplication sharedApplication].networkActivityIndicatorVisible = NO; 
}

1 个答案:

答案 0 :(得分:0)

您应该在移动设备中打开调试控制台并查看是否存在java脚本错误,否则您应该通过警报进行调试。

启用调试控制台:

打开设置 - > Safari - >开发人员(在底部) - >调试控制台开启|关闭