[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] [已解决]vbs自动登录网站为何报错对象不支持此属性或方法?

  1. username = "gds"
  2. password = "123"
  3. Dim IE,er
  4. Set IE = CreateObject("InternetExplorer.Application")
  5. IE.Navigate "http://192.168.255.243/"
  6. IE.Visible = True
  7. Do Until IE.ReadyState = 4
  8.     WScript.Sleep 1000
  9. Loop
  10. IE.Document.getElementById("DDDDD").innerText = username
  11. IE.Document.getElementById("upass").innerText = password
  12. IE.Document.getElementById("0MKKey").submit
复制代码
下面是网页代码:
<html><head>
<script language="JavaScript"><!--
sv=0;sv1=0;v6='http://[::]:9002/v6                                     ';myv6ip='                                       ';

if(sv==1&&sv1==0)window.location=v6;
function mysubmit(){if(sv1==1)document.form1.v6ip.value=myv6ip;return true;}
// --></script>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网关登陆                                </title>
<style><!--
a {text-decoration: none}
.f1 { font-size: 9pt; font-family: Verdana; line-height: 14pt }
.f2 { font-size: 8pt; font-family: Verdana; line-height: 12pt }
-->
</style></head><body><form name=form1 method=post action="/" onSubmit="return mysubmit()">
<center>
<table width=600 border=0 height=80%>
<tr>
<td height=100%>
<div align=center>
<center>
<table width=350 border=0 height=397 bgcolor=#FFFFFF cellspacing=0 cellpadding=0 style="border-collapse: collapse" bordercolor=#111111>
<tr>
<td height=60 width=350 colspan=2>
                        <p align=center>
<img border=0 src=4.gif width=350 height=44></td>
</tr>
<tr>
<td height=70 width=350 colspan=2>
<div align=center><font ; font color=000000>                                                                                                                                                                                                        </font></div>
<div align=center style="width: 352; height: 20"><font ; font color=000000></font></div></td></tr>
<tr>
<td height=28 width=350 class=f1 align=right colspan=2 bgcolor=#94A9BE>
                        <p align=center class=f1><font color=#FFFFFF>请输入您的帐号和密码</font></td>
</tr>
<tr>
<td height=65 width=163 class=f1 align=right bgcolor=#D3DCE4>帐号 Account :</td>
<td height=65 width=187 class=f1 bgcolor=#D3DCE4>
<p>&nbsp;<input name=DDDDD size=16 maxlength=26 style=" BACKGROUND-COLOR: rgb(255,255,255); BORDER-BOTTOM: rgb(0,0,0) 1px solid; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-RIGHT: rgb(0,0,0) 1px solid; BORDER-TOP: rgb(0,0,0) 1px solid"></p>
                        </td>
</tr>
<tr>
<td height=15 width=163 class=f1 align=right bgcolor=#D3DCE4>密码 Password :</td>
<td height=15 width=187 class=f1 bgcolor=#D3DCE4>
                        <p>&nbsp;<input type=password name=upass size=16 maxlength=16 style=" BACKGROUND-COLOR: rgb(255,255,255); BORDER-BOTTOM: rgb(0,0,0) 1px solid; BORDER-LEFT: rgb(0,0,0) 1px solid; BORDER-RIGHT: rgb(0,0,0) 1px solid; BORDER-TOP: rgb(0,0,0) 1px solid"></p>
</td>
</tr>
<tr>
<td height=70 width=350 colspan=2 bgcolor=#D3DCE4><p align=center>
<input type=submit name=0MKKey value="登录 Login" style=" BACKGROUND-COLOR: rgb(105,130,150); BORDER-BOTTOM: rgb(100,130,160) 1px solid; BORDER-LEFT: rgb(139,141,218) 1px solid; BORDER-RIGHT: rgb(23,24,79) 1px solid; BORDER-TOP: rgb(194,217,227) 1px solid; COLOR: rgb(255,255,255); font-size: 9pt; font-family: Verdana; height: 25; width: 85">&nbsp;&nbsp;&nbsp;
<input type=reset name=1MKKey value="重置 Reset" style=" BACKGROUND-COLOR: rgb(105,130,150); BORDER-BOTTOM: rgb(23,24,79) 1px solid; BORDER-LEFT: rgb(139,141,218) 1px solid; BORDER-RIGHT: rgb(23,24,79) 1px solid; BORDER-TOP: rgb(194,217,227) 1px solid; COLOR: rgb(255,255,255); font-size: 9pt; font-family: Verdana; height: 25; width: 85"></td>
<input type="hidden" name="v6ip" value="">
</tr>
<tr>
<td height=28 width=350 colspan=2 bgcolor=#94A9BE>
<p class=f1 align=center><a href=9.htm><font color=#FFFFFF>修改密码 Edit Pass</font></a></td>
</tr>
<tr>
<td height=51 width=350 bgcolor=#D3DCE4 colspan=2>
                        <p align=center class=f2><font size=1><br>
</font>&copy; 2003 <a target=_blank href=http://www.doctorcom.com>CITY HOTSPOT</a>. All Rights Reserved.&nbsp;</td></tr>
</table></center></div></td></tr></table></center></form></body></html>f2o_demo1").innerHTML;
  

   
我怎么运行都不行,老是在最后一行报错——对象不支持此属性或方法。
请大家帮我指点指点,谢谢啦!
1

评分人数

    • zqz0012005: 感谢给帖子标题标注[已解决]字样PB + 2

getElementById 改为 getElementsByName

TOP

回复 2# Seder


    不行,还是报同样的错。

TOP

不对吧,还有个s你加了没?手机看图看不清

TOP

回复 4# Seder


    什么S?

TOP

两个单词你没发现不同?getElementById 与 getElementsByName后者有一个s

TOP

回复 6# Seder


    还是报同样的错。

TOP

本帖最后由 manhua 于 2012-3-16 10:42 编辑
  1. username = "gds"
  2. password = "123"
  3. Dim IE,er
  4. Set IE = CreateObject("InternetExplorer.Application")
  5. IE.Navigate "http://192.168.255.243/"
  6. IE.Visible = True
  7. Do Until IE.ReadyState = 4
  8.     WScript.Sleep 1000
  9. Loop
  10. IE.Document.getElementById("DDDDD").innerText = username
  11. IE.Document.getElementById("upass").innerText = password
  12. IE.Document.getElementById("0MKKey").click
复制代码
问题已经解决了,上面是代码。感谢Seder 帮助!

TOP

getElementById竟然可以通过name属性获取元素??
是IE特有功能?还是 input type=submit 元素的确可以这么做?

最好还是用 document.getElementsByName("0MKKey")(0).click

TOP

回复 9# powerbat


    这个我就不清楚了,但我这个程序是可以正常登录,并显示登录成功的界面。

TOP

回复 9# powerbat


    果然是IE only.
IE能够用getElementById通过name属性获取input元素,除input之外随便试了几个标签,都不行。
1

评分人数

TOP

回复 10# manhua


    你这完全是瞎猫碰上死耗子,别人说了正确方法你还不知道怎么用。

知其然就要知其所以然。其实我对HTML根本不熟,只是偶尔翻过一些html方面的资料,都说getElementById要通过id属性获取元素,无意中看到这个帖子,我马上来了好奇心,就想到去探究一下。

TOP

回复  manhua


    你这完全是瞎猫碰上死耗子,别人说了正确方法你还不知道怎么用。

知其然就要知其 ...
powerbat 发表于 2012-3-15 22:33



     你管我怎么用,我又没针对谁,你这个人有毛病啊!!!!
    愤青一个! :L :L :L :L :L :L :L :L :L :L :L

TOP

返回列表