gpt4 book ai didi

javascript - 在 Firefox 中关闭窗口

转载 作者:行者123 更新时间:2023-11-30 06:04:13 25 4
gpt4 key购买 nike

我想关闭窗口。我的脚本在 ie 和 firefox 2.x 中运行良好,但在 firefox 3.x 及更高版本中不起作用。我正在使用以下脚本。

function closeWindow() {
window.open('', '_self', ''); //bug fix
window.close();
}

请找到一些解决方案。感谢大家。

最佳答案

function closeWindow() {
if (navigator.appName != "Microsoft Internet Explorer") {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserWrite");
}
alert("This will close the window");
window.open('', '_self');
window.close();
}

这适用于 firefox 和 ie

关于javascript - 在 Firefox 中关闭窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6148056/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com