简体   繁体   中英

How to block window.showModalDialog popups from a BHO?

I am working on a BHO popups / ads blocker, and I can't find how to block this js triggered popup:

var popDialogOptions = "dialogWidth:795px; dialogHeight:500px; center:1; menubar:1; tollbar:1; location:0; resizable:1; scroll:1; status:1; fullscreen;yes";
eval("window.showModalDialog('http://uri.com/popup.html,'',popDialogOptions)");

I am intercepting DISPID_NEWWINDOW, DISPID_NEWWINDOW2 and DISPID_NEWWINDOW3 but none of those are being fired, but the popup does open.

How could I block this type of popups?

I'm not very familiar with IE BHOs, however, regarding JavaScript itself: have you considered adding at the beginning of the page

window.showModalDialog = new Function();

eg by inserting new <script> as a first child of <head> (prevents popup for me in IE8/XP) or this is too brutal (because it blocks modal dialogs at all)?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM