disallow window open in javascript

后端 未结 2 1013
深忆病人
深忆病人 2021-01-05 06:40

How can I disable window.open() using html, javascript, jQuery...?
I mean block any window open attempt, making \"not-working\" all existing window.open() f

2条回答
  •  执笔经年
    2021-01-05 07:37

    //for iframes:
    $.each($('iframe'), function() {
        this.contentWindow.open = function (url, windowName, windowFeatures) {
            //iframe window.open caught!
        };
    });
    
    //for window:
    window.open = function (url, windowName, windowFeatures) {
        //window.open caught!
    };
    

提交回复
热议问题