本文介绍了javascript检测浏览器关闭选项卡浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 这下面的代码工作正常,但这段代码执行每一个事件但我想点击浏览器关闭按钮这下面的代码执行...给出建议 < script > window.CloseEvent(beforeunload,function(e) { var confirmationMessage =Vamsi Vakati; (e || window.event).returnValue = confirmationMessage; return confirmationMessage; } ); < / script > 先谢谢你解决方案 请尝试如下。 注意:这只是一个样本。根据你的应用程序确定它。 window.addEventListener( beforeunload,function(e){ var confirmationMessage = \ o /; (e || window。 event )。returnValue = confirmationMessage; // Gecko + IE return confirmationMessage; // Webkit,Safari,Chrome等。 }); 点击此处查看更多信息: beforeunload Hi ,This below code working Fine but this code execute every event But i want when click the browser close Button this below code execute ... Give the suggestions<script> window.CloseEvent("beforeunload", function (e) { var confirmationMessage = "Vamsi Vakati"; (e || window.event).returnValue = confirmationMessage; return confirmationMessage; });</script>Thank You in Advance 解决方案 Please try is as below.Note: This is just a sample.Adjust it according to your app.window.addEventListener("beforeunload", function (e) { var confirmationMessage = "\o/"; (e || window.event).returnValue = confirmationMessage; //Gecko + IE return confirmationMessage; //Webkit, Safari, Chrome etc.});Check here for more info : beforeunload 这篇关于javascript检测浏览器关闭选项卡浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 阿里云证书,YYDS! 05-24 00:45