我用Google搜索了&我嘗試了幾個答案,但我的問題仍在發生。我在IIS 7上有一個.net網頁,代碼在IE9中正常工作,但在Firefox中不起作用。我需要它在兩個工作。不知道我做錯了什麼,請幫忙。javascript settimeout div not showing
這是一個簡單的頁面有一個多行文本框,當我點擊提交一個隱藏的DIV應該彈出並說,請稍等,而這個過程...不要點擊任何東西(他們可能會提交1000個項目,所以它需要時間。)
有什麼奇怪的是我注意到,如果我取消註釋警報按鈕,警報彈出,我實際上看到的DIV,但如果我拿走警報按鈕,我沒有看到它。
這裏是我的javascript。
function do_totals1()
{
// alert("Here-1");
document.getElementById('pleasewaitScreen').style.display = 'block';
// alert("Here-2!");
do_totals2();
window.setTimeout(function() {
"do_totals2()";
}, 4000);
//
// alert("Here-3!");
// window.setTimeout("do_totals2()", 1);
}
function do_totals2()
{
alert("Here-4!");
wait(4000);
document.getElementById('pleasewaitScreen').style.display = 'none';
}
<div id="pleasewaitScreen" style="display:none;position:absolute;z-index:5;top:50%;left:5%;">
<table bgcolor="#000000" border="1" style="border-color:blue; height:300;width:400" cellpadding="0" cellspacing="0">
<tr>
<td style="width:100%;height:100%" bgcolor="#CCCCCC" align="center" valign="middle">
<br /><br />
<font face="Helvetica,Verdana,Arial" size="5" color="#000066"><b>Processing... Don't click on anything until ESN(s) populate the grid below.</b></font>
<br /><br />
</td>
</tr>
</table>
</div>
「不工作」對我們沒有任何意義。你期望發生什麼?究竟發生了什麼?你讀過[faq](http://stackoverflow.com/faq)嗎? – Shmiddty
當他們提交表單時會發生什麼?是否調用了do_totals1函數?提供更多信息。它不完整。 – Rocky
這不是問題的根源,而是''do_totals2()「;'不應該用引號引起來。更重要的是,你很明顯沒有向我們展示一些東西,因爲代碼中沒有循環。就像現在一樣,你的代碼顯示'div'然後立即隱藏它。 –