[code="java"]
<html>
<head>
<script language="javascript">
var thisPage=false;
window.onbeforeunload=function checkLeave(e){
var evt = e ? e : (window.event ? window.event : null); //此方法为了在firefox中的兼容
if(!thisPage)evt.returnValue='离开会使编写的内容丢失。';
}
function sumbit(){
thisPage=true;
document.getElementById('YourFormId').submit();
}
</script>
</head>
<body>
<p><a href='http://www.baidu.com'>baidu.com</a></p>
<form id='YourFormId' action='http://www.baidu.com'>
<input type="button" name="button" id="button" value="提交" onclick="sumbit();"/>
</form>
</body>
</html>
附件里有html可以看下效果
http://topic.youkuaiyun.com/t/20060823/13/4969625.html
本文介绍了一个使用 JavaScript 实现的页面离开提示功能。当用户尝试离开当前页面且未保存更改时,会弹出警告框提醒用户可能会丢失已输入的内容。此外,还提供了一个提交按钮用以触发表单提交。

8449

被折叠的 条评论
为什么被折叠?



