且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

父窗口关闭时关闭所有子窗口

更新时间:2023-11-18 15:36:40

找到适用于最新版Chrome,Firefox和IE的正确解决方案(jQuery)。

Found a proper solution (jQuery) that works in the lastest versions of Chrome, Firefox and IE.

最初想要使用jQuery $()。unload() function( http://api.jquery.com/unload/ )但它自1.8以来已被弃用( http://bugs.jquery.com/ticket/11733 )。由于 $()。unload() $()的快捷方式.bind('unload',fn) ,我试图使用基本的,它的工作原理。

Initially wanted to use jQuery $().unload() function (http://api.jquery.com/unload/) but it's deprecated since 1.8 (http://bugs.jquery.com/ticket/11733). Since $().unload() is the shortcut for $().bind('unload', fn), I tried to use the basic one and it worked.

$(window).on('unload', function() {
    closeAll();
});