您好,欢迎访问一九零五行业门户网

javascript如何关闭浏览器事件

javascript关闭浏览器事件的方法:1、使用onbeforeunload方法,关闭或刷新浏览器会触发此事件;2、使用popstate方法,代码为【history.pushstate(123, null, document.ur】。
本教程操作环境:windows7系统、javascript1.8.5版,dell g3电脑。
javascript关闭浏览器事件的方法:
1、onbeforeunload
关闭或刷新浏览器会触发此事件
示例代码
window.onbeforeunload = function(ev) { return true;};
2、popstate
示例代码
window.history.pushstate("123", null, document.url);window.addeventlistener("popstate", function() { _this.ismsgshow = true; history.pushstate("123", null, document.url);});
相关免费学习推荐:javascript视频教程
以上就是javascript如何关闭浏览器事件的详细内容。
其它类似信息

推荐信息