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 webView
s in your simulator. For instance, try document.location
in your inspector to see what actually is the URL when the page doesn't open.