jQuery unload() 方法
jQuery 教程
· 2019-03-09 22:57:56
实例
当离开页面时,显示提示消息:
$(window).unload(function(){
alert("Goodbye!");
});
alert("Goodbye!");
});
定义和用法
unload() 方法在 jQuery 版本 1.8 中被废弃,在 3.0 版本被移除。
Firefox 与 Chrome 会阻止弹窗,所以没办法看到效果。
当用户离开页面时,会发生 unload 事件。
当发生以下情况下,会触发 unload 事件:
- 点击某个离开页面的链接
- 在地址栏中键入了新的 URL
- 使用前进或后退按钮
- 关闭浏览器窗口
- 重新加载页面
unload() 方法规定当 unload 事件发生时会发生什么。
unload() 方法只应用于 window 对象。
注意:unload 事件在不同浏览器中效果不一样,请确保使用前在所有浏览器测试该方法。
语法
$(selector).unload(function)
| 参数 | 描述 |
|---|---|
| function | 必需。规定当触发 unload 事件时运行的函数。 |
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html
Coding the Matrix
Philip N. Klein / Newtonian Press / 2013-7-26 / $35.00
An engaging introduction to vectors and matrices and the algorithms that operate on them, intended for the student who knows how to program. Mathematical concepts and computational problems are motiva......一起来看看 《Coding the Matrix》 这本书的介绍吧!