<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> <lang> <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><br></lang> </div>