从 UIWebView 检测 window.open() [英] Detect window.open() from UIWebView

查看:23
本文介绍了从 UIWebView 检测 window.open()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

小问题:是否可以使用 UIWebViewDelegateUIWebView 中检测 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()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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