How to close a window using jQuery

前端 未结 5 1663
隐瞒了意图╮
隐瞒了意图╮ 2020-12-15 03:29

How to close a window using jQuery for all browser compatibility?



        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-15 04:30

    You can only use the window.close function when you have opened the window using window.open(), so I use the following function:

    function close_window(url){
        var newWindow = window.open('', '_self', ''); //open the current window
        window.close(url);
     }
    

提交回复
热议问题