-3

我希望能够自动登录到站点。为此,我保存了该站点登录页面的副本。然后我提前在这个副本上输入密码和用户名。此页面上有一个登录按钮。所以通常,在输入用户名和密码后,我需要点击这个按钮进入下一页。但我想自动执行此操作。以下是源代码的相关部分:

<html>
<head>
<meta http-equiv="imagetoolbar" content="no">
<link rel="SHORTCUT ICON" href="/favicon.ico">
<SCRIPT>var main=window;</SCRIPT><SCRIPT LANGUAGE="JavaScript" src="http://localhost/_common/cjmaker.js"></SCRIPT>

<title>Login Page</title>
<SCRIPT LANGUAGE="JavaScript">  function openNewBrowserWindow() { newWindow = window.open("http://localhost/_common/lvl5/dologin.html", "subWind", "statusbar,menubar,resizable"); newWindow.focus(); }  function getUsername() { return document.getElementById("nameInput").value; }   function getPassword() { return document.getElementById("pass").value; }   function setFocus() { document.getElementById('nameInput').value == "" ? document.getElementById("nameInput").focus() : document.getElementById("pass").focus(); } </SCRIPT><style type="text/css">
<!--
td {  font-family: Arial, Helvetica, sans-serif; font-size: 18px; }
body { font-size:12px; vertical-align:baseline; padding:0; margin:0px; height:1px; font-family:arial;color:#A8A8A8; background-color:#000000;}

.normText { color:#A8A8A8;  }
.normTextBold  { font-weight:bold; }
.bigText  { font-size: 30px; font-weight: bold }
.bigRedText  { font-size: 30px; color: #FF0000; font-weight: bold }
.legalTextArea { font-size:10px; color:A8A8A8; background-color:000000}
.smallText { font-size:12px }
-->
</style></head>
<body style="height:100%" SCROLL="NO" onload="setFocus();document.getElementById('loginForm').submit();">


<table border=0 cellpadding=0 cellspacing=0 style="width:100%; height:100%">
<tr height="27px" style="max-height:27px;"> 
    <td valign="bottom" width="14" height="27px"> <img width="14"  height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb5.gif"></td>
    <td valign="bottom" width="13" height="27px"><img width="13"  height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb6.gif"></td>
    <td valign="bottom" width="100%" style="position: relative; background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionb7.gif'); background-repeat: repeat-x;"  height="27px"></td>
    <td valign="bottom" width="14" height="27px"> <img width="14"  height="27" src="http://localhost/_common/lvl5/skin/graphics/login/sectionb8.gif"></td>
  </tr>
   <tr> 
    <td width="10" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionc5.gif'); background-repeat: repeat-y;"> 
    </td>
    <td COLSPAN="2"> 
<form id="loginForm" method="post" name='loginForm' action="http://localhost/_common/servlet/lvl5/login?language=en" onsubmit="document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value);" ></form>
        <div align="center"><img src="/logo.gif" width="536"></div>
        <table border="0" align="center" name="logintable" >
          <tr>
             <td colspan="3">&nbsp;</td></tr><tr><td align="center" colspan=3 height="100"><span class="normText"><span class="bigRedText">Dealer Copy</span></span><br><span class="normText"><span class="normRedText">This software is only licensed for internal use by a Dealer for Automated Logic Corporation</span><BR><SPAN class="smallText">Serial Number&nbsp;(&nbsp;W200500023&nbsp;)</SPAN></SPAN></span></td>
          </tr><tr><td colspan="3">&nbsp;</td></tr>
          <tr> 
            <td colspan=3 align="center">Please log in</td>
          </tr>
          <tr> 
            <td width="50%" align="right"> 
              <div align="right" style="margin-right:10px;">Name:</div>
            </td>
            <td> 
              <div align="left"> 
                <input id="nameInput" type="text" value="Administrator" name="name" size="25" maxlength="80" tabindex="1" style="width:175px;">
              <script>
                 if(document.getElementById('nameInput').value == '')
                 {
                   document.getElementById('nameInput').focus();
                 }
              </script>
              </div>
            </td>
            <TD rowspan="2" width="50%" align="left"> 
              <div align="left" style="margin-left:10px;"> 
                <input type="submit" id="submit" name="Submit" style="background-color:#A8A8A8" value="Log in" tabindex="2">&nbsp;&nbsp;
              </div>
            </TD>
          </tr>
          <tr> 
            <td> 
              <div align="right" style="margin-right:10px;">Password:</div>
            </td>
            <td> 
              <div align="left"> 
                <input type="password" value="" id="pass" name="pass"  autocomplete="off" size="25" maxlength="80" tabindex="1" style="width:175px;  ">
              <script>
                 if(document.getElementById('nameInput').value != '')
                 {
                   document.getElementById('pass').focus();
                 }
              </script>
              </div>
            </td>
            </tr>
       </table>
             </td>
    <td valign="top" width="14" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectionc8.gif'); background-repeat: repeat-y"> 
      <span id="actionVbar" style="position:relative; width=100%; height=100%"></span> 
    </td>
  </tr>
  <tr height="14px"  style="max-height:14px"> 
    <td  valign="top"><img width="14" height="14" src="http://localhost/_common/lvl5/skin/graphics/login/sectiond5.gif"></td>
    <td  COLSPAN="2" valign="top" style="background-image: url('http://localhost/_common/lvl5/skin/graphics/login/sectiond6.gif'); background-repeat: repeat-x; line-height: 14px;" height="14px">&nbsp;</td>
    <td  valign="top" height="14px"><img  width="14" height="14" src="http://localhost/_common/lvl5/skin/graphics/login/sectiond8.gif"></td>
  </tr>
</table><div id="imagecachediv" style="position:absolute; z-index:-10; top:0px; left:0px; visibility:hidden" >
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_left.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_down_right.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_left.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/acbutton_up_right.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_left.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_dn_right.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_left.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/actions/actionbutton_up_right.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/facets/facettab_down_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/facets/facettab_up_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/buttons/textbutton_down_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/buttons/textbutton_up_middle.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointtempindicator.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointheader.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointbody.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/properties/equip_templates/setpt_graphics/setpointfooter.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/uphashes.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/horiz.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/leftdiagonal.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/vert.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/tickbackground.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/patterns/squares.gif">

   <IMG SRC="http://localhost/_common/lvl5/graphics/main/de/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/en/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/es/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/th/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/scheduleticks_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/de/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/en/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/es/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/th/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/scheduleticks_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/scheduleticks_24.gif">

   <IMG SRC="http://localhost/_common/lvl5/graphics/main/de/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/en/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/es/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/th/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/schedulefooter_12.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/de/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/en/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/es/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/fr_FR/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ko/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/ru/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/sv/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/th/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/vi/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh/schedulefooter_24.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/zh_TW/schedulefooter_24.gif">

   <IMG SRC="http://localhost/_common/lvl5/graphics/main/trpixel.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollup.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrolldown.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollleft.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/actscrollright.gif">

   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollslider.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollhchan.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollvchan.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollup.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrolldown.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollleft.gif">
   <IMG SRC="http://localhost/_common/lvl5/skin/graphics/scrollbar/navscrollright.gif">

   <IMG SRC="http://localhost/_common/lvl5/graphics/main/propscrollhchan.gif">
   <IMG SRC="http://localhost/_common/lvl5/graphics/main/propscrollvchan.gif">
</div>

</body>
</html>

我试图做的是添加一个脚本,例如

<SCRIPT LANGUAGE="JavaScript">document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value;</SCRIPT> 

位于“FORM”块的“onsubmit”部分内的相同代码。但它没有用。

你能帮我解决这个问题吗?

提前致谢。

4

3 回答 3

1

document.getElementById('loginForm').submit();<body>event 上添加标签onLoad

例如, <body onload="document.getElementById('loginForm').submit();">

于 2012-06-18T13:42:34.637 回答
1

我通过简化解决了这个问题。

<html>

<title>Login Page</title>

<body onload="document.getElementById('loginForm').submit();">

<form id="loginForm" method="post" name='login' action="http://localhost/_common/servlet/lvl5/login?language=en" onsubmit="document.getElementById('pass').value = CJMaker.makeString(document.getElementById('pass').value);" >

<input id="nameInput" type="text" value="Administrator" name="name" size="25" maxlength="80" tabindex="1" style="width:175px;">

<input type="password" value="" id="pass" name="pass"  autocomplete="off" size="25" maxlength="80" tabindex="1" style="width:175px;  ">

</form> 

</body>
</html>
于 2012-06-19T08:23:26.093 回答
0

调用此代码

$('#nameInput').val('user name');
$('#pass').val('password');
$('#loginForm').submit();

尝试上面的代码自动登录。我认为它会起作用。

于 2012-06-18T13:17:33.323 回答