【发布时间】:2013-09-20 13:19:38
【问题描述】:
我在beforeunload javascript 事件期间提交我的表单。
对于所有浏览器,它的行为方式都不同。
在 chrome 29 中,如果我在 1 分钟内关闭浏览器,那么它会触发服务器端操作,但如果我的应用程序空闲超过 1 分钟然后我关闭浏览器,那么它不会触发服务器。同样在 IE10 和 FF20 中,我不能闲置超过 5 分钟。
<script>
function updateServerCMIModel(item) {
document.forms[0].itemID.value = item;
formstring = top.window.CPFrame.showCurrentModelState("form");
document.forms[0].data.value = formstring;
document.forms[0].nextAction.value = top.window.frames.CPFrame.CPAPI.userEvent;
document.forms[0].lmsAction.value = "update";
document.forms[0].submit();
}
</script>
有没有办法解决这个问题?
【问题讨论】:
-
如果您不关闭浏览器,而是按例如 HOME 按钮,它可以工作吗?
-
是的,如果我点击页面内的任何链接,它就可以工作。但要求是在浏览器关闭时保存详细信息。
-
如何创建一个对象并使用对象信息触发一个 ajax 发布请求?这对你有用吗?
标签: javascript forms