如何关闭一个grepmonkey脚本的Firefox选项卡? [英] How do I close a firefox tab from a greasemonkey script?
本文介绍了如何关闭一个grepmonkey脚本的Firefox选项卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
window.close();我们有一个用这个单行代码的greasemonkey用户脚本。
但firefox不允许用户脚本关闭一个窗口(如错误控制台)
有没有解决这个问题的方法?
解决方案
<您需要更改Firefox(about:config)的配置设置才能允许这样做。
步骤:
- 转到地址栏并键入 about:config
- 转到参数 dom。 allow_scripts_to_close_windows
- 将其值设为 true
现在你的脚本可以通过'window.close()'来关闭TAB。
例如
function closeTab(){
window.open('','_self','');
window.close();
}
I have a greasemonkey user script with this single line of code...
window.close();
but firefox does not allow a user script to close a window (as reported by an error message in the error console)
Is there a work around to this problem?
解决方案
You need to change configuration settings of Firefox (about:config) to allow this.
Steps:
- Go to address bar and type about:config
- Go to parameter dom.allow_scripts_to_close_windows
- Set its value as true
Now your script can close the TAB with 'window.close()'
eg.
function closeTab(){
window.open('', '_self', '');
window.close();
}
这篇关于如何关闭一个grepmonkey脚本的Firefox选项卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文