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()”事件调用。
看到第一个警报“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()
调用导致向服务器发送完整消息,这类似于页面刷新,意味着未触发以下 javascript。
关于javascript - setTimeout() 目标函数永远不会触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32916159/