Detect window.open() from UIWebView

前端 未结 2 837
独厮守ぢ
独厮守ぢ 2021-01-02 14:27

Short question: Is it possible to detect window.open() in a UIWebView using the UIWebViewDelegate or is there another way to reach thi

相关标签:
2条回答
  • 2021-01-02 14:34

    You need to overwrite window.open() using JavaScript:

    [webView stringByEvaluatingJavaScriptFromString:@"window.open = function (open) { return function  (url, name, features) { window.location.href = url; return window; }; } (window.open);"];
    
    0 讨论(0)
  • 2021-01-02 14:37

    Try using this delegate methods. Hope this helps.

    - (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType;
    - (void)webViewDidStartLoad:(UIWebView *)webView;
    
    0 讨论(0)
提交回复
热议问题