How to override the window.open functionality?

前端 未结 3 1536
走了就别回头了
走了就别回头了 2020-12-07 23:38

Let\'s say I have window.open (without name parameter), scattered in my project and I want to change the implementation so that wherever name is not specified I\'ll specify

3条回答
  •  一向
    一向 (楼主)
    2020-12-08 00:07

    P.s. In simple terms what I want to do is override the window.open functionality.

    var orgOpen = window.open;
    
    window.open = function (...args) {
        alert("Overrided!"); 
        return orgOpen(...args); 
    }
    
    window.open("http://www.stackoverflow.com");
    

提交回复
热议问题