捕捉弹出窗口并通知Firefox用户 [英] Catch popup window and notify user in Firefox

查看:230
本文介绍了捕捉弹出窗口并通知Firefox用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个网站随机出现在他们的网站上的一些活动弹出窗口。这将是非常有用的,如果一个用户会被通知当一个弹出窗口显示在该网站在Firefox等,可以在JavaScript的帮助下,或任何附加等?
在此先感谢。

解决方案



nsIWindowWatcher - https://developer.mozilla.org/en-US/docs/ XPCOM_Interface_Reference / nsIWindowWatcher



nsiWindowMediator - https://developer.mozilla.org/zh-CN/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator



这是nsiwindowmediator的一种方式:

$ $ $ $ $ $ $ $ $ start $ window $ var windowListener = {
onOpenWindow:function(aXULWindow){
//等待窗口完成加载
让aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal | | Ci.nsIDOMWindow);
aDOMWindow.addEventListener('load',function(){
aDOMWindow.removeEventListener('load',arguments.callee,false);
//加载窗口,现在网站会加载addeventlistener为
//检查网站加载是在这里,如果它的竞选事情然后阻止
},false);
},
onCloseWindow:function(aXULWindow){},
onWindowTitleChange:function(aXULWindow,aNewTitle){},
};
/ * end - windowlistener * /

Services.wm.addListener(windowListener);
//Services.wm.removeListener(windowListener);

所以现在在onOpenWindow中,你可以看到什么是开窗器,如果是那个网站,然后关闭那个窗口。


There is a web site that randomly shows up some campaign popup windows on their web site. It would be very useful if a user would be notified when a popup is shown up on that site in Firefox, etc. Can it be possible with the help of javascript, or any add-on, etc.? Thanks in advance.

解决方案

Two options.

nsIWindowWatcher - https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIWindowWatcher

nsiWindowMediator - https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIWindowMediator

This is the nsiwindowmediator way:

/*start - windowlistener*/
var windowListener = {
    onOpenWindow: function (aXULWindow) {
        // Wait for the window to finish loading
        let aDOMWindow = aXULWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowInternal || Ci.nsIDOMWindow);
        aDOMWindow.addEventListener('load', function () {
            aDOMWindow.removeEventListener('load', arguments.callee, false);
            //window loaded, now the website will load so addeventlistener for that
            //check what the website loading is here, if its your campain thing then block it
        }, false);
    },
    onCloseWindow: function (aXULWindow) {},
    onWindowTitleChange: function (aXULWindow, aNewTitle) {},
};
/*end - windowlistener*/

Services.wm.addListener(windowListener);
//Services.wm.removeListener(windowListener);

so now in the onOpenWindow, you can see what is the window opener, if it was that website, then close that window.

这篇关于捕捉弹出窗口并通知Firefox用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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