admin管理员组文章数量:1336401
I am debugging a website using firebug. The website opens a window, performs some operations and than closes it. This causes me to lose all of the firebug net history. Is there any way to prevent javastript from closing the window after its done, except changing the code?
I am debugging a website using firebug. The website opens a window, performs some operations and than closes it. This causes me to lose all of the firebug net history. Is there any way to prevent javastript from closing the window after its done, except changing the code?
Share asked Feb 26, 2012 at 14:10 Arsen ZahrayArsen Zahray 25.4k50 gold badges141 silver badges233 bronze badges 2- I had the exact same problem. I ended up adding a breakpoint in the js code at the place that triggered the close so that I could inspect the net history up to that point. – beldaz Commented Oct 25, 2017 at 19:30
- 1 This makes me extremely angry. How could any browser allow such an action to be performed from a web page?! I want to set things on fire. – Andrew Commented Sep 20, 2018 at 15:35
2 Answers
Reset to default 4You can rewrite the open
method, which adds a beforeunload
event. Have a look at the annotated code + bookmarklet below:
Code:
javascript:(function(w){
var o = w.open; /* Stores original `window.open` method */
w.open = function() { /* Catches all window.open calls*/
var x = o.apply(w, arguments); /* Calls original window.open */
/* Bind beforeunload event */
x.addEventListener('beforeunload',function(e){e.preventDefault()},true);
return x;
}
})(window);
Bookmarklet:
javascript:(function(w){var o=w.open;w.open=function(){var x=o.apply(w,arguments);x.addEventListener('beforeunload',function(e){e.preventDefault()},true);return x;}})(window);
I haven't tried to use it, but there's a settings in FF which supposedly lets you do what you wish.
Type about:config in the url bar and press enter. After a warning you'll see the list of config options. Search for dom.allow_scripts_to_close_windows and set its value to false.
本文标签: How to prevent javascript inside firefox from closing a windowtabStack Overflow
版权声明:本文标题:How to prevent javascript inside firefox from closing a windowtab? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742403046a2468266.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论