iOS UIWebView popup blocker issue

爷,独闯天下 提交于 2019-12-13 02:20:37

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/37102931/ios-uiwebview-popup-blocker-issue

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!