Detect window.open() from UIWebView

前端 未结 2 856
独厮守ぢ
独厮守ぢ 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);"];
    

提交回复
热议问题