我有一個彈出窗口,當用戶同時打開和關閉彈出窗口時,它給腳本錯誤。下面的代碼在彈出窗口中使用。彈出窗口卸載問題
<html>
<head>
<script src="../../StaticContent/Scripts/jquery-1.7.2.min.js"
type="text/javascript"></script>
<script src="../../StaticContent/Scripts/jquery-ui-1.8.20.custom.js"
type="text/javascript"></script>
<script type="text/javascript" language="javascript">
function CloseWarning() {
return "Do you want to close the window";
}
function onload()
{
}
</script></head>
<body onbeforeunload="return CloseWarning();" onload="onload();">
//Some html
<script type="text/javascript" language="javascript">
$(document).ready(
function() {
//Some code
});
</script>
</body>
</html>
我嘗試了degubbing,它在$(document).ready()行發出錯誤。我認爲是因爲在完全加載HTML之前關閉彈出窗口導致了這個問題。
任何線索?
你爲什麼要這麼做? – thecodeparadox
發佈CloseWarning函數 – coolguy
您是否包含'jquery.js'? –