Javascript:Onbeforeunload
我有以下javascriptJavascript:Onbeforeunload,javascript,onbeforeunload,Javascript,Onbeforeunload,我有以下javascript <script type="text/javascript"> window.onbeforeunload = function (beforeclose) { var message = 'Are you sure that you want to close the greenhouse!!!'; if (typeof beforeclose == 'undefined') {
<script type="text/javascript">
window.onbeforeunload = function (beforeclose) {
var message = 'Are you sure that you want to close the greenhouse!!!';
if (typeof beforeclose == 'undefined') {
beforeclose = window.event;
}
if (beforeclose) {
beforeclose.returnValue = message;
}
return message;
}
</script>
window.onbeforeunload=函数(beforeclose){
var message='您确定要关闭温室吗!!!';
if(typeof beforeclose==“未定义”){
beforeclose=window.event;
}
如果(关闭前){
beforeclose.returnValue=消息;
}
返回消息;
}
此方法是在关闭前向用户发出的警报。我想要的是在关闭窗口后使用一个方法。比如:“当下一页关闭时,做点什么”。是否有类似于onafterunload的功能?否,当浏览器或选项卡关闭时,就不会有类似于onafterunload的功能,此时您无法运行。是,您可以处理服务器端会话退出事件。否没有此类事件可用,但您可以使用:
$(window).unload(function() {
//do something
}
关闭窗口后无法执行任何操作。看,这篇文章也有同样的问题: