iOS UIWebView popup blocker issue

2019-08-14 14:30发布

In iOS, the default behavior when I open my webpage is that after login it opens the next page in a new window. But now when I open it in iOS webview, it does not open the next page. I google about it, and the cause seems to be the popup blocker. So, is there any simple way to disable the popup blocker in the iOS webview?

标签: ios uiwebview
1条回答
爷、活的狠高调
2楼-- · 2019-08-14 14:52

The webpage might have a redirection that you are not handling properly.

You may first want to use webView:didFailNavigation:withError: or webView:didFailProvisionalNavigation:withError: to get some reasons or clues. And you can try to debug webView:decidePolicyForNavigationAction:decisionHandler: to see whether you are allowing the navigation.

If the redirection somehow generates an about:blank page in the transition, you could try to use UIWebViewDelegate's webView:shouldStartLoadWithRequest:navigationType: and returns a YES if request.URL.absoluteString is indeed about:blank, for example:

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    if ([request.URL.absoluteString isEqualToString:@"about:blank"]) {
        return YES;
    }
    return NO;
}

BTW, you also can try to use Safari to debug webViews in your simulator. For instance, try document.location in your inspector to see what actually is the URL when the page doesn't open.

查看更多
登录 后发表回答