猿问
如何停止一次访问同一个网站标签?
如何停止从多个选项卡访问用户的同一网站页面?我可以用javascript来做吗?
DIEA
浏览 87
回答 1
1回答
喵喵时光机
找到了。 <script type="text/javascript"> window.onload = function(){ if (document.cookie.indexOf("_instance=true") === -1) { document.cookie = "_instance=true"; // Set the onunload function window.onunload = function(){ document.cookie ="_instance=true;expires=Thu, 01-Jan-1970 00:00:01 GMT"; }; // Load the application } else { alert(" Security Alerts.You Are Opening Multiple Window. This window will now close."); var win = window.open("about:blank", "_self"); win.close(); // Notify the user } };</script>
0
0
0
随时随地看视频
慕课网APP
相关分类
JavaScript
我要回答