好.我已经看到这个问题已经超过10年未得到答复了..
如何在一键通话中提交和关闭弹出窗口.
建议如此运行.
function saveNClose()
{
document.form.submit();
self.close();
}
this doesn't work because the submit has a redirect, and the self.close is never reached.
function closeLaterNSaveNow();
{
setTimeout("window.close()",5000);
document.form.submit();
}
same problem.. the close is never called because the script for the page is gone.
function closeNowNSubmit()
{
self.close();
document.form.submit();
}
the window closes, but nothing gets saved. server doesn't even get notified of anything..
<input class='btn btn-success' disabled='disabled' id='SubmitFinal' onclick='closeWindow()' type='submit' value='Finish'>
Well then there's no validation of the data. it submits before the function is called.
任何人解决这个?我找到了可以追溯到2002年的相同解决方案,有些解决方案可以追溯到本月.我会继续看,但我希望有人钉了它,有人在这里回答
解决方法:
一个典型的解决方案是输出一个JS片段,它将在提交后关闭窗口作为结果页面.
<script type="text/javascript">
window.close();
</script>
另一种解决方案是通过AJAX提交表单数据,并在请求完成时关闭窗口.您可以使用jQuery Form plugin:
$("#myForm").ajaxForm(function() {
window.close();
})