用户登录后如何重定向?

时间:2013-11-07 15:30:37

标签: javascript html forms redirect

我有一个安全区域登录表单。这些通常会被处理,然后用户被带到特定页面,该页面是安全区域的登录页面。我想更改登录表单,以便以相同的方式记录它们,但允许我将它们重定向到不同的页面。我怎样才能用javascript来完成这个?这样做的原因是我有近3000个订阅者到这个安全区域,并且不想为不同的安全区域复制它们。非常感谢任何帮助。

html表格:

<form name="catseczoneform74513" onSubmit="return checkWholeForm74513(this)" method="post" action="https://redlakewalleye.worldsecuresystems.com/ZoneProcess.aspx?ZoneID=12369&amp;Referrer={module_siteUrl,true,true}&amp;OID={module_oid}&amp;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 checkWholeForm74513(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();return false;}
            //]]>
        </script>
    </form>

2 个答案:

答案 0 :(得分:2)

要使用javascript将用户重定向到其他位置,请使用以下命令:

window.location.href = "http://www.example.com";

如上所述here,另一种方法如下:

window.location.replace("http://stackoverflow.com");

第一个模拟点击链接的行为,另一个模拟HTTP重定向。

答案 1 :(得分:0)

您可以使用document.location.href = "link";