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

标签 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>

最佳答案

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

关于Javascript,如何提交表单,然后关闭当前窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19915391/

相关文章:

html - 没有 child 的选择器?

django - 如何将类、id、占位符属性添加到 django 模型表单中的字段

javascript - jQuery - 返回数组中包含文本字符串的所有对象

javascript - jQuery fullPage : All images loading at same time

javascript - 在无效函数输入时返回未定义或抛出错误?

javascript - 过滤十六进制颜色

javascript - 融合层中可以拥有的不同标记数量是否有限制?

javascript - 用于数据选择的多个 TreeView

javascript - HTMLFormElement 的操作

java - ActionEvent 文本字段检查