gpt4 book ai didi

javascript - 提交表单,然后打开新窗口并关闭弹出窗口

转载 作者:行者123 更新时间:2023-11-28 08:45:05 25 4
gpt4 key购买 nike

我有一个出现在弹出窗口中的登录表单。我想编写一些javascript(不确定是否应该使用常规js或Ajax),它将在提交表单后打开一个新的全尺寸窗口,然后关闭当前登录表单弹出窗口。我怎样才能做到这一点?我知道我的问题是,在正常情况下,表单提交后您无法执行任何其他操作,因为页面刷新/重定向等。感谢您对我的问题的任何帮助或解决方案。

我看过这个问题:Submit a form in a popup, and then close the popup但无法理解它,或者它是否适用于我的问题。

表格:

<form name="catseczoneform30738" onSubmit="return checkWholeForm30738(this)" method="post" action="https://redlakewalleye.worldsecuresystems.com/ZoneProcess.aspx?ZoneID=12695&Referrer={module_siteUrl,true,true}&OID={module_oid}&OTYPE={module_otype}">
<div class="form">
<div class="item">
<label for="SZUsername">Username</label>
<br />
<input class="cat_textbox_small" type="text" name="Username" id="SZUsername" maxlength="255" />
</div>
<div class="item">
<label for="SZPassword">Password</label>
<br />
<input class="cat_textbox_small" type="password" name="Password" id="SZPassword" maxlength="255" autocomplete="off" />
</div>
<div class="item">
<input type="checkbox" name="RememberMe" id="RememberMe" />
<label for="RememberMe">Remember Me</label>
</div>
<div class="item">
<input class="cat_button" type="submit" value="Log in" name="submitButton" />
</div>
</div>
<script type="text/javascript" src="/CatalystScripts/ValidationFunctions.js"></script>
<script type="text/javascript">
//<![CDATA[
function checkWholeForm30738(theForm){
var why = "";
if (theForm.Username) why += isEmpty(theForm.Username.value, "Username");
if (theForm.Password) why += isEmpty(theForm.Password.value, "Password");
if (why != ""){
alert(why);
return false;
}
window.open('http://www.redlakewalleye.com/promotional/activation-form','_blank');
theForm.submit();
// window.close(); here?
return false;
}
//]]>
</script>

</form>

最佳答案

将此放在 theForm.submit() 之前:

var popup = window.open('http://www.redlakewalleye.com/promotional/activation-form','_blank');
theForm.onsubmit = function() {
popup.close();
}

关于javascript - 提交表单,然后打开新窗口并关闭弹出窗口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19932757/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com