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

Submit Form, then open new window and close popup

本文关键字:窗口 表单 然后 新窗口 提交      更新时间:2023-09-26

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

我已经看过这个问题:在弹出窗口中提交表单,然后关闭弹出窗口但无法理解它,或者它是否适用于我的问题。

形式:

<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();
}

在新窗口中,由您的登录表单打开的窗口,写下以下内容:

<script type="text/javascript">
if(window.opener != null) {
  window.opener.close(); // close login form
}
</script>