小问题:是否可以使用 UIWebViewDelegate
在 UIWebView
中检测 window.open()
还是有其他方法可以达到这?当触发 window.open()
-Event 以显示 UIAlertView
时,我需要 url.
Short question: Is it possible to detect window.open()
in a UIWebView
using the UIWebViewDelegate
or is there another way to reach this? I need the the url when a window.open()
-Event is fired to show a UIAlertView
.
你需要用 JavaScript 覆盖 window.open()
:
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);"];
这篇关于从 UIWebView 检测 window.open()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!