function redirectHome() {
alert("here1");
function setHref() {
alert("here2");
window.parent.location.href="fprIndex.html?action=edit&aspect=<%=request("aspect")%>&id=<%=request("Request_ID")%>";
};
document.forms["form1"].submit();
var timer = setTimeout(setHref, 1000);
}
redirectHome()通過按鈕「onClick()」事件調用。setTimeout()目標函數永遠不會觸發
看到第一個警報「here1」,但「here2」從未見過。
怎麼了?
什麼工作,如果我只是:
function redirectHome() {
document.forms["form1"].submit();
window.parent.location.href="fprIndex.html?action=edit&aspect=<%=request("aspect")%>&id=<%=request("Request_ID")%>";
}
什麼,我要做的就是實現從表單提交的時間延遲1秒,以重定向發生的時間 - 對於純粹的審美原因。
是不是'.submit()'提交一個表單,它發送你的頁面往返?因此,消除'location.href'發生,因爲在超時完成之前頁面已經消失了? –
當您打開您的控制檯時,您是否看到任何錯誤? –
根據你的編輯:然後在'setHref()'方法內移動'.submit()'行並忘記'location.href'行。像這樣:http://jsfiddle.net/zxd59bz7/ –