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

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

问题描述

简短问题:是否可以使用<$ c在 UIWebView 中检测 window.open() $ c> UIWebViewDelegate 还是有另一种方法可以达到这个目的吗?当触发 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天全站免登陆