Disable window in javascript

How to disable window.open() using html, javascript, jQuery ...?
I mean blocking any attempt to open a window, rendering all existing window.open () functions “inoperative”.
What are the best ways to do this? (also works with iframes)

+5
source share
2 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! }; 
+3
source

You will pollute the global namespace, but you can just override the window.open method ...

 window.open = function (url, windowName, windowFeatures) { console.log('not opening a window'); } 
+1
source

All Articles