Hi, guys. Here's another sample script in VBScript. It opens internet explorer, navigates to google, sets up a search field and submits a query.
set ie = CreateObject("InternetExplorer.Application")
ie.navigate("www.google.com")
ie.visible = true
while ie.readystate <> 4
wscript.sleep 100
WEnd
set fields = ie.document.getelementsbyname("q")
set buttons = ie.document.getelementsbyname("btnG")
fields(0).value = "some query"
buttons(0).click
Everything goes o.k.
And here is a script in JScript, that is supposed to do the very same thing:
var ie = new ActiveXObject("InternetExplorer.Application");
ie.visible = true;
ie.navigate("www.google.com");
do {
WScript.Sleep(100);
} while (ie.readystate !== 4);
var input = ie.document.getElementsByName("q");
var button = ie.document.getElementsByName("btnG");
input(0).value = "some query";
button(0).click;
It sets up search field to "some query" correctly, but it doesn't click the button! Literally, nothing happens after input(0).value = "some query";
line.
I'm new to JScript, so I wonder, whether it's me being stupid and ignorant about some specific details, or not?