为什么这个网页不能自动填表,
用的 WebBrower控件打开网页,等网页打开完后单击填表,网上的各种方法都试过,都没反映,
这是填表代码
我用MsgBox vDoc.All(i).tagName看了一下,出来只有7个内容 head, title,html,meta,frameset,frame,根本就没有INPUT标签,也就是说下面的UCase$(vDoc.All(i).tagName) = "INPUT"代码根本没有进入运行到,
网页代码看了也很普通啊,为什么会找不到INPUT标签,帮我看看哪里不对
Private Sub Command1_Click()
Set vDoc = Web1.Document
Dim i As Integer
For i = 0 To vDoc.All.length - 1
MsgBox vDoc.All(i).tagName
If UCase$(vDoc.All(i).tagName) = "INPUT" Then
Set Item = vDoc.All(i)
If Item.Type = "text" Or Item.Type = "password" Then
Select Case Item.Name
Case "USER"
Item.Value = "user-name" '要改为自己的账号
Case "PSWD"
Item.Value = "user-password" '要改为自己的密码
End Select
End If
Next i
End Sub
以下是网页代码
<html>
<head>
<title>登录
</title>
<link rel="stylesheet" href="/hw.css">
<SCRIPTLANGUAGE="JavaScript" >
if (navigator.appName.indexOf("Microsoft") == -1)
{
window.location.href="/LoginJsOff.jsp";
}
</SCRIPT>
<SCRIPTLANGUAGE="JavaScript" SRC="/help.js"></SCRIPT>
<SCRIPTLANGUAGE="JavaScript" SRC="/check.js"></SCRIPT>
<SCRIPTLANGUAGE="JavaScript">
function onerror(msg, URL,lineNum)
{
var errWin=window.open("","error","HEIGHT=600,WIDTH=800");
varwintxt= "<HTML><BODY BGCOLOR=RED>";
wintxt += " Error:" +msg+ "\r\n";
wintxt += " URL:" +URL+ "\r\n";
wintxt += " Line:" +lineNum+ "\r\n";
errWin.document.write(wintxt);
errWin.document.close();
return false;
}
function Catch()
{
//alert(event.keyCode);
if(event.keyCode==122)
{
setTimeout("document.location.reload()",2000);
}
}
function checkIE()
{
}
</SCRIPT>
</head>
<!-- <bodybgcolor="#FFFFFF" onload="checkIE();document.frmMain.USER.focus();"> -->
<body bgcolor="#FFFFFF"
onload="window.focus();setinputfocus('divMain','frmMain','USER');bShowHelp = true;"
onkeyup="Catch()">
<DIV id=tooltip2 style="HEIGHT:100px; RIGHT: 25px;POSITION: absolute;TOP: -50px;VISIBILITY:hidden;z-index:70; WIDTH: 150px"></DIV>
<div id="divMain" style="position:absolute;left:200px;top:98px; width:500px;z-index:40">
<FORM NAME="frmMain"
AutoComplete="OFF"
ACTION="/servlet/servletSPEC.Login"
TARGET="login_blank1374395972404"
METHOD="POST"
onSubmit="returnValidEnter(this)">
<table align=centerwidth=70%>
<tr><TD NOWRAP colspan=2align=rightclass="TITLE">登录
<a href="javascript:void(0)" onclick = open_HelpWindow("/help/helpsrc/welcome/welcom_to_use_normal.htm","newSysmgHelpWin")>[在线帮助]</a>
</td></tr>
<tr><TD NOWRAP colspan=2><hr noshade size=1width=100%></td></tr>
<tr>
<TDNOWRAP colspan=2 align=center class="WARN">注意:打*号的项目必须填
<br><br></td>
</tr>
<tr>
<TDNOWRAP>操作员名
</td>
<TDNOWRAP><input type=text maxlength=16 name="USER" OnMouseOver="help('USER','50'); return true;" OnMouseOut="nd(); return true;">*</td>
</tr>
<tr>
<TDNOWRAP>登录密码
</td>
<TDNOWRAP><input type=password maxlength=16 name="PSWD" OnMouseOver="help('PSWD','50'); return true;" OnMouseOut="nd(); return true;">*</td>
</tr>
<tr>
<TDNOWRAP>选择后台服务器
</td>
<TDNOWRAP><select name="SMP"OnMouseOver="help('SMP','50'); return true;" onMouseOut="nd(); return true;">
<optionvalue=0selected> aaaaaaa </option>
</select>*
</td>
</tr>
<tr>
<TDNOWRAP colspan=2 nowrap><INPUT TYPE="hidden" NAME="jsON" value="on"></td>
</tr>
<tr>
<TD> </td>
<TDNOWRAP><INPUT TYPE="hidden"name="isIE"></td>
</tr>
<tr>
<TD> </td>
<TD><input type=submit value="确 定"
> <input type=reset value="重 置"
></td>
</tr>
</table>
<input type=hidden name=usertype value="OPRM">
</form>
</div>
<div id="OtherServer" style="position:absolute; left:10px;top:120px; width:180px;height:500px; z-index:80">
<table border=0 cellspacing=5 width=180>
<tr><td colspan=2>当前服务器:</td></tr>
<tr><td> <font color="#800000">noname</font></td></tr>
</table>
</div>
<DIV ID="overDiv" STYLE="position:absolute;visibility:hide; z-index: 7;"></DIV>
<div id="title"style="position: absolute; left: 10; top: 2; width: 730; height: 83; z-index: 5">
<table width="101%" border="0" cellspacing="0" height="50">
<tr>
<td> </td>
</tr>
<tr valign=top>
<TD NOWRAP width="34%" ><img src="/images/title.jpg" width="249" height="50"></td>
<TD NOWRAP width="37%" ><img src="/images/change.gif" width="290" height="50"></td>
<TD NOWRAP width="37%" >
<table border="0" cellpadding="0" cellspacing="0" >
<tr >
<td> </td>
<td height=18 background="/images/pat-help.jpg" width=160 >
<a href="/help/helpsrc/welcome/wl.htm" target=blank>帮助</a> <a href="/about.html" target=blank>关于我们</a>
</td>
</tr>
</table>
</TD>
</tr>
</table>
</div>
<div id="main" style="position:absolute; left:261px; top:98px; width:470px;height:389px; z-index:1"><img src="/images/main.jpg" width="508" height="431"></div>
<div id="left" style="position:absolute; left:12px;top:101px; width:150px;height:172px; z-index:3"><img src="/images/banner-left.jpg"width="170"height="510"></div>
<SCRIPTLANGUAGE="JavaScript">
var newWin=null;
function ValidEnter(form)
{
if(navigator.appName.indexOf("Microsoft")!=-1)
{
form.isIE.value="yes";
}
if(navigator.appName.indexOf("Netscape")!=-1)
{
form.isIE.value="no";
}
if(!ValidId(form.USER,'50'))
{
return false;
}
if(!ValidNull(form.USER,'50',false))
{
return false;
}
if(!ValidLength(form.USER,'50',1,16))
{
return false;
}
if(!ValidPassWord(form.PSWD,'50',6,16,false))
{
return false;
}
if(navigator.appName.indexOf("Microsoft")!=-1)
{
window.parent.close();
}
// 打开另一个窗口
if(!newWin || newWin.closed )
{
if(navigator.appName.indexOf("Microsoft")!=-1)
{
newWin = window.open("", "login_blank1374395972404");
}
else
{
newWin = window.open("", form.target);
return true;
}
}
else
{
newWin.focus();
}
return true;
} //end of ValidEnter()
</script>
<script language=javascript>
function findlayer(layerid)
{
var i=0;
layerid=""+layerid+"";
for (i=0;i<alllayer.length;i++)
{
if (alllayer[i].id.toUpperCase()==layerid.toUpperCase())
return alllayer[i];
}
return false;
}
//得到页面中所有的layer对象
function getalllayer(rootlayer)
{
var i=0;
if (rootlayer==window) alllayer.length=0;
for (i=0;i<rootlayer.document.layers.length;i++)
{
alllayer[alllayer.length]=rootlayer.document.layers[i];
}
for (i=0;i<rootlayer.document.layers.length;i++)
{
if (rootlayer.document.layers[i].document.layers.length>0)
{
getalllayer(rootlayer.document.layers[i]);
}
}
}
if (document.layers) getalllayer(window);
</script>
</SCRIPT>
<script language="javascript">
var i=0;
help_ary.length=0;
help_ary[i++]="USER";
help_ary[i++]="USER,50";
help_ary[i++]="PSWD";
help_ary[i++]="PSWD,50";
help_ary[i++]="SMP";
help_ary[i++]="SMP,50";
</script>
</body>
</html>
[解决办法]
把网址贴出来
[解决办法]
Sub Command2_Click()
On Error Resume Next
With CreateObject("internetexplorer.application")
.Visible = True
.Navigate "https://61.236.121.13:8443/Login.jsp"
Do Until .ReadyState = 4
DoEvents
Loop
.document.All("USER").Value = "synpb"
.document.All("PSWD").Value = "1234567890"
.document.All.tags("option")(0).Selected = True
.document.All.tags("input")(4).Click
End With
End Sub
.SetRequestHeader "Content-Type", "application/x-www-form-urlencoded"
.SetRequestHeader "Content-Length", Len(PostData)
.SetRequestHeader "Connection", "Keep-Alive"
.SetRequestHeader "Cache-Control", "no-cache"
If Cookie <> "" Then .SetRequestHeader "Cookie", Cookie
.Send (PostData)
.WaitForResponse
PostByWinHttp = BytesToBstr(.ResponseBody, "GBK")
End With
Set XmlHttp = Nothing
End Function