使用onbeforeunload关闭窗口时跳到其它页面
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body onbeforeunload="unload();">
<a href="javascript:void(window.open('about:blank'));">Click Me</a>
<form action="http://sohu.com" target="_blank" name="form" id="form">
</form>
<script>
function unload(){
document.getElementById("form").submit();
}
</script>
</body>
</html>
分享到:
相关推荐
Onunload,onbeforeunload都是在刷新或关闭时调用,可以在[removed]脚本中通过[removed]来指定或者在<body>里指定。区别在于onbeforeunload在onunload之前执行,它还可以阻止onunload的执行。 Onbeforeunload...
百度之,有onbeforeunload与onunload这两个事件,但是onbeforeunload在用户刷新的时候也会执行。搞得我弄的挺久的,所以想在这里做一个小小的总结 onbeforeunload与onunload事件 onbeforeunload定义和用法 ...
页面刷新时先执行onbeforeunload,然后onunload,最后onload。 经过验证我得出的结论是: //对于ie,谷歌,360: //页面加载时只执行onload //页面刷新时,刷新之前执行onbeforeunload事件,在新页面即将替换旧页面...
NULL 博文链接:https://primarykeylw.iteye.com/blog/1568120
1)异同点 相同点:onunload,onbeforeunload都是在刷新或关闭时调用,可以在[removed]脚本中通过[removed]来指定或者在<body>里指定。 不同点: a)onbeforeunload在onunload之前执行 ,它还可以阻止onunload的...
NULL 博文链接:https://yuanyuan7891.iteye.com/blog/619615
Onbeforeunload也是在页面刷新或关闭时调用,Onbeforeunload是正要去服务器读取新的页面时调用,此时还没开始读取;而onunload则已经从服务器上读到了需要加载的新的页面,在即将替换掉当前页面时调用。Onunload是...
onbeforeunload事件 它是这样用的: 代码如下:[removed] g_blnCheckUnload = true; function RunOnBeforeUnload() { if (g_blnCheckUnload) { window.event.returnValue = ‘You will lose any unsaved content...
javascript Onunload与Onbeforeunload使用小结.docx
自制网页页面加载动画:效果一与效果二(含有HTML字符实体+CSS动画animation+js事件onbeforeunload、onload实现)
这个功能其实很简单,就是通过处理window、body或frameset对象或元素的onbeforeunload事件实现的。 这个unbeforeunload的具体用法我就不说了,反正几乎能引起当前页面发生跳转的任何动作,都会触发这个事件。并且它...
获得用户登陆状态不用说...BODY onbeforeunload=”body_onUnload()”> [removed] [removed] = function() { if (window.event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey) { alert(“浏
ember install ember-onbeforeunload用法首先,将ConfirmationMixin混合到您的Ember.Route 。 默认情况下,路由model hasDirtyAttributes ( )会在每次卸载前提示用户。 // app/routes/foo.jsimport Ember from '...
页面中的使用到Iframe时,我们如何需要对IFrame中页面是否改变进行判断,我们可以使用到window.onbeforeunload事件.
NULL 博文链接:https://liuzidong.iteye.com/blog/730771
引言项目开发需要关闭标签页时,弹窗提示用户【数据将不被保存,是否继续操作】实现该功能,则需要监听浏览器是否关闭下面来学习涉及到浏览器关闭的两个方法onbefor