日期:2014-05-17 浏览次数:20664 次
window.onbeforeunload = function() { thisHREF = window.location.href; if(thisHREF.indexOf("当前页url")==-1) { alert('页面未保存!'); return false; }
------解决方案--------------------
<script> window.onbeforeunload = function() { var bPostSelf = true; var obj = document.activeElement; if(obj!=null && obj.tagName !="body" && obj.tagName !="HTML") { if(obj.tagName.toLowerCase() == "a" && obj.href.indexOf("__doPostBack")==-1) { bPostSelf = false; } }else { bPostSelf = false; } if(!bPostSelf) { alert("请保存数据!"); return false; } } </script>