如何停止一次访问同一个网站标签?

如何停止从多个选项卡访问用户的同一网站页面?我可以用javascript来做吗?



DIEA
浏览 67回答 1
1回答

喵喵时光机

找到了。&nbsp;<script type="text/javascript">&nbsp; &nbsp; window.onload = function(){&nbsp; &nbsp; if (document.cookie.indexOf("_instance=true") === -1) {&nbsp; &nbsp; document.cookie = "_instance=true";&nbsp; &nbsp; // Set the onunload function&nbsp; &nbsp; window.onunload = function(){&nbsp; &nbsp; &nbsp; &nbsp; document.cookie ="_instance=true;expires=Thu, 01-Jan-1970 00:00:01 GMT";&nbsp; &nbsp; };&nbsp; &nbsp; // Load the application&nbsp; &nbsp; }&nbsp; &nbsp; else {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert(" Security Alerts.You Are Opening Multiple Window. This window will now close.");&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var win = window.open("about:blank", "_self"); win.close();&nbsp; &nbsp; // Notify the user&nbsp; &nbsp; }&nbsp; &nbsp; };</script>
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript