gpt4 book ai didi

Javascript/Html 关闭窗口事件

转载 作者:行者123 更新时间:2023-12-03 06:12:09 25 4
gpt4 key购买 nike

我试图在 html 和 js 中执行此操作,但不刷新或重新加载,只是在关闭时触发。我使用了 onbeforeunload、unload 等函数,但它们不起作用。
sample image

最佳答案

用 jQuery 试试这个:

$(window).bind('beforeunload', function(){
return 'Are you sure you want to leave?';
});

或者使用 JavaScript

window.onbeforeunload = function(){
return 'Are you sure you want to leave?';
};

关于Javascript/Html 关闭窗口事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39270546/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com