需要一个JQuery脚本来禁止或拦截任何window.open方法执行 [英] Need a JQuery script that will prohibit or intercept any window.open methods from executing

查看:110
本文介绍了需要一个JQuery脚本来禁止或拦截任何window.open方法执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果页面有window.open函数。该页面用于多个网站。在它的移动版本中。该特定页面需要一个J Query脚本,它将禁止或拦截任何window.open方法执行。

If page has window.open function. That page is used in multiple website. In a mobile version of it. That particular page need a J Query script that will prohibit or intercept any window.open methods from executing.

推荐答案

window对象不提供像before-open之类的任何事件(或其他与开放相关的事件),所以你不能拦截它...

唯一已知的 - 对我来说 - 解决方法是覆盖window.open函数...

window object does not provide any event like before-open (or other open-related events), so you can not intercept it...
The only known - to me - solution is to override window.open function...
window.open_original = window.open;

window.open = function(url, name, features, replace) {
    alert("!");

    window.open_original(url, name, features, replace);
}

window.open("http://www.codeproject.com");

http:// jsfiddle.net/5fLkb2zx/ [ ^ ]


这篇关于需要一个JQuery脚本来禁止或拦截任何window.open方法执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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