IE 9错误getElementbyId:需要对象 [英] IE 9 error getElementbyId: Object required
本文介绍了IE 9错误getElementbyId:需要对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
出于某种原因,下面的VBS就像IE 8中的魅力一样,但是在我的笔记本电脑上的IE9中
我在 .getElement
中得到了Object。
for some reason, VBS below works like a charm in IE 8, but in IE9 on both of my Laptops
I get Object Required at .getElement
.
我该如何解决这个问题。
How can I fix this please.
WScript.Quit Main
Function Main
Set IE = WScript.CreateObject("InternetExplorer.Application", "IE_")
IE.Visible = True
IE.Navigate "http://desistream.tv/en/index.shtml"
Wait IE
With IE.Document
.getElementByID("login_username").value = "myuser"
.getElementByID("login_password").value = "mypass"
.getElementByID("frmLogin").submit
End With
End Function
Sub Wait(IE)
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
Do
WScript.Sleep 500
Loop While IE.ReadyState < 4 And IE.Busy
End Sub
Sub IE_OnQuit
On Error Resume Next
WScript.StdErr.WriteLine "IE closed before script finished."
WScript.Quit
End Sub
编辑
这是我到目前为止在JScript中得到的东西
this is what I got so far in JScript
var WshShell = WScript.CreateObject("WScript.Shell");
WshShell.Run("Chrome www.desistream.tv", 10, true);
WScript.Sleep(500);
推荐答案
您需要使用正确的名称。您提供的名称是Name属性,而不是ID,因此:
You need to use the right names. The names you have given are the Name property, not the ID, so:
.getElementByID("login_username").value = "myuser"
.getElementByID("login_password").value = "mypass"
应该be:
.getElementByID("username").Value = "myuser"
.getElementByID("pass").Value = "mypass"
这篇关于IE 9错误getElementbyId:需要对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文