admin管理员组文章数量:1391943
I try to set up a simple logoff-page which should close after 3 seconds.
Regarding this Question is it possible to wait before that action?
<script type="text/javascript">
sleep(3000);
window.open('', '_self', '');
window.close();
</script>
With the sleep nothing happens at all.
Edit:
The solution of @Sidius works well in IE without a prompt.
Unfortunately Firefox blocks the Script:
Scripts can not close any windows that were not opened by the script
I try to set up a simple logoff-page which should close after 3 seconds.
Regarding this Question is it possible to wait before that action?
<script type="text/javascript">
sleep(3000);
window.open('', '_self', '');
window.close();
</script>
With the sleep nothing happens at all.
Edit:
The solution of @Sidius works well in IE without a prompt.
Unfortunately Firefox blocks the Script:
Share Improve this question edited May 23, 2017 at 12:07 CommunityBot 11 silver badge asked Dec 3, 2015 at 15:17 BlueFoxBlueFox 1711 gold badge2 silver badges13 bronze badges 5Scripts can not close any windows that were not opened by the script
-
1
window.setTimeout(function(){},time);
? – www139 Commented Dec 3, 2015 at 15:19 - Are you saying that the new window opens, it waits 3 seconds and then closes? – www139 Commented Dec 3, 2015 at 15:21
- Does that hack to close a browser you did not open really still work? – epascarello Commented Dec 3, 2015 at 15:23
- @www139 nothing happens. – BlueFox Commented Dec 3, 2015 at 15:42
- Check my edited answer @BlueFox – Sidius Commented Dec 3, 2015 at 15:51
3 Answers
Reset to default 4try this:
window.open('', '_self', '');
setTimeout(function(){
window.close();
}, 3000);
Edit: I think firefox might be a little more strict with the
window.open()
function. You might want to give values to the function's constructor.
window.open(URL,name,specs,replace);
In example:
window.open("", "", "width=200, height=100");
You can use setTimeout() API to achieve the same -
setTimeout(window.close,3000);
You need to use window.setTimeout()
:
window.open('', '_self', '');
// Add this instead.
setTimeout(function(){
window.close();
}, 3000);
本文标签: javascriptWaitsleep before windowclose()Stack Overflow
版权声明:本文标题:javascript - Waitsleep before window.close() - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744742495a2622691.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论