Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

disallow window open in javascript

How can I disable window.open() using html, javascript, jQuery...?
I mean block any window open attempt, making "not-working" all existing window.open() functions.
Which are the best ways to do it? (working also in case of iframes)

like image 897
neoDev Avatar asked May 02 '15 04:05

neoDev


1 Answers

//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!
};
like image 50
Samurai Avatar answered Sep 27 '22 22:09

Samurai