[code="java"]
<html>
<head>
<script language="javascript">
var thisPage=false;
window.οnbefοreunlοad=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="提交" οnclick="sumbit();"/>
</form>
</body>
</html>
附件裏有html可以看下效果
http://topic.csdn.net/t/20060823/13/4969625.html