Javascript,如何提交表单,然后关闭当前窗口?

时间:2013-11-11 20:33:39

标签: javascript html forms

我有一个弹出式登录表单。我希望表单提交,然后关闭该弹出窗口。我怎么能做到这一点?窗口当前设置为在函数返回之前关闭。在这种情况下window.close()在哪里?谢谢你的帮助。

形式:

<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" />
                &nbsp;<a href="/_System/SystemPages/PasswordRetrieveRequest">Lost password?</a></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;
        }
    theForm.submit();
    window.open('http://www.redlakewalleye.com/promotional/activation-form','_blank');
    window.close();
    return false;
    }
//]]>
       </script>            
</form>

1 个答案:

答案 0 :(得分:0)

如果可能,应将window.close()作为服务器响应的一部分包含在提交事件中。如果您将window.close()作为表单上提交的一部分包含在内,则会导致您的表单在提交实际发生之前关闭。