<div class="codetitle"> <span><a style="CURSOR: pointer" data="45054" class="copybut" id="copybut45054" onclick="doCopy('code45054')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code45054"> <br> <br> <br> <br><meta charset="UTF-8"> <br><meta name="Keywords" content=""> <br><meta name="Description" content=""> <br><title>js离开当前页面前判断条件提示是否要离开页面</title> <br><script type="text/javascript"> <BR>window.onbeforeunload = function() <BR>{ <BR>var unloads = document.getElementById("unloads").value; <BR>if(unloads == null || unloads == ""){ <BR>return "您确定要退出页面吗?"; <BR>} <BR>} <BR></script> <br> <br> <br><input type="text" id="unloads" name="unloads" value=""> <br> <br> <br> </div>