iOS UIWebView 弹出窗口拦截器问题 [英] iOS UIWebView popup blocker issue

查看:46
本文介绍了iOS UIWebView 弹出窗口拦截器问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iOS 中,我打开网页时的默认行为是登录后在新窗口中打开下一页.但是现在当我在 iOS webview 中打开它时,它不会打开下一页.我谷歌了一下,原因似乎是弹出窗口阻止程序.那么,有没有什么简单的方法可以禁用 iOS webview 中的弹出窗口拦截器?

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?

推荐答案

网页可能有一个您没有正确处理的重定向.

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

您可能首先想使用 webView:didFailNavigation:withError:webView:didFailProvisionalNavigation:withError: 来获取一些原因或线索.您可以尝试调试 webView:decidePolicyForNavigationAction:decisionHandler: 以查看是否允许导航.

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.

如果重定向以某种方式在转换中生成了一个 about:blank 页面,您可以尝试使用 UIWebViewDelegatewebView:shouldStartLoadWithRequest:navigationType: 并返回 YES 如果 request.URL.absoluteString 确实是 about:blank,例如:

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;
}

顺便说一句,您也可以尝试使用 Safari 在模拟器中调试 webViews.例如,在检查器中尝试 document.location 以查看页面未打开时的实际 URL.

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.

这篇关于iOS UIWebView 弹出窗口拦截器问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆