2

编辑:问题的改变

如果我的代码是这样的:

<form name="login" action="https://login.extremebb.net/login" method="post"

                >

                <input type="hidden" name="dst" value="/status.html" />

                    <label for="username"><b>Username: </b></label>

                    <input class="field" type="text" name="username" value="" size="23" />

                    <label for="password"><b>Password:</b></label>

                    <input class="field" type="password" name="password" size="23" />

                    <input type="submit" name="submit" value="Login" />

                <input type="hidden" name="redirect_to" value="/status.html"/>

                </form> 

我应该怎么做才能让它在页面加载或一段时间后自动提交?

注意:在浏览器中保存的用户名和密码

4

3 回答 3

1
<html>
<body onload="document.getElementById('submit').click()">
    <form name="subfrm" action="../New%20folder%20(3)/success.html">
        <input type="hidden" name="dst" value="/success.html" />
        <label for="username"><b>Username: </b></label>
        <input class="field" type="text" name="username" value="" size="23" />
        <label for="password"><b>Password:</b></label>
        <input class="field" type="password" name="password" size="23" />
        <input type="submit" name="submit" value="Login" id="submit" />
        <input type="hidden" name="redirect_to" value="../New%20folder%20(3)/success.html"/>
    </form>
</body>
</html>
于 2012-09-10T17:30:18.873 回答
1

我认为您的错误出在您的提交按钮name="submit"!将其更改为ANYTHING_ELSE并工作!

<body onload="document.subfrm.submit();">
    <form name="subfrm"  action="../New%20folder%20(3)/success.html">
    <input type="hidden" name="dst" value="/success.html" />
    <label for="username">
        <b>Username: </b>
    </label>
    <input class="field" type="text" name="username" value="" size="23" />
    <label for="password">
        <b>Password:</b></label>
    <input class="field" type="password" name="password" size="23" />
    <input type="submit" name="ANYTHING_ELSE" value="Login" />
    <input type="hidden" name="redirect_to" value="../New%20folder%20(3)/success.html" />
    </form>
</body>
于 2012-09-10T17:33:00.163 回答
0

您可以手动单击提交按钮,但您需要给它一个 id 才能使用 getElementById。我不确定,但我认为 document.[name of element] 不兼容跨浏览器。

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
    </head>

<body onload="document.getElementById('submitButton').click();"  >
    <form id="subfrm"  name="subfrm" action="/Quantifi/" >
        <input type="hidden" name="dst" value="/success.html" />
        <label for="username"><b>Username: </b></label>
        <input class="field" type="text" name="username" value="" size="23" />
        <label for="password"><b>Password:</b></label>
        <input class="field" type="password" name="password" size="23" />
        <input type="submit" id="submitButton" name="submit" value="Login" />
        <input type="hidden" name="redirect_to" value="/Quantifi"/>
    </form>     
</body>
</html>

编辑:正如其他人所提到的,将您的提交按钮命名为“提交”也会导致问题。如果您提供其他东西的按钮和 ID/名称,则以下内容将适用于 onload 事件:

<body onload="document.getElementById('subfrm').submit();"  >
于 2012-09-10T17:38:12.353 回答