我建立一個aspx頁面,在不同的窗口調用另一個網頁,通過JavaScript按鈕:無聊的JavaScript調用:爲什麼一個不需要的js函數被調用?
function assuntos() {
window.open("pg_assuntos.aspx", "List", "scrollbars=no,resizable=no,width=600,height=480");
}
在頁面的onload事件,我的代碼:
bot_cadastrar.Attributes.Add("onclick", "assuntos()")
當我點擊按鈕,一切都會是正確的。但每次我更新一個執行查詢的fild時,似乎都會引發「onclick」事件或函數似乎被執行,因爲窗口已打開。我也有在onload事件另一個代碼用於啓動秒錶javascript函數:
VB代碼:
Dim script = "<script language = javascript>" & _
"window.setTimeout('ShowTime()', 1000);</script>"
ClientScript.RegisterStartupScript(Me.GetType, "iniciar", script)
ASPX代碼(JavaScript的):
function ShowTime() {
var dt = new Date();
var dif = dt - dtIn;
var tim = new Date();
tim.setHours(0, 0, 0, dif);
document.getElementById("<%= cmp_hora.ClientID %>").value = dt.toLocaleTimeString();
document.getElementById("<%= cmp_tempo.ClientID %>").value = tim.toLocaleTimeString();
window.setTimeout("ShowTime()", 1000);
}
爲什麼功能已開始爲自己?我受夠了這些彈出窗口!
不錯的提示,但窗口仍然顯示。當窗體被加載時,窗口沒有被操作,但是當我執行一個在文本框中輸入[Enter]的查詢時,該函數被引發。 – Alex