首页 > 其他 > 详细

系统可能不会保存你所做的修改 onbeforeunload

时间:2018-05-26 14:42:51      阅读:955      评论:0      收藏:0      [点我收藏+]

网上找了好多实现这个的方法,说的还是不明白。害得我(我自己的原因)以为是需要在服务器环境下才能跑通 window.onbeforeunload; 后来猜想是不是函数返回值发生变化就会触发,于是对了。

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<script src="https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js"></script>
<body>
<input type="text" id = ‘input‘ value = ‘kkk‘>
</body>
<script>

window.onbeforeunload = function() { 
    return $(#input).val()
}
</script>
</html>

 

系统可能不会保存你所做的修改 onbeforeunload

原文:https://www.cnblogs.com/aiyr/p/9092811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!