WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

OLE with MSIE
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Execute a Java Script from a Webpage

 Keywords: vbscript  javascript script client side HTML Web page

Question:

How can I execute a vbscript or javascript (basically any client side) function that exists in an HTML page?

For example, there's this internal web site that has an EXPORT feature to dump data properly to a file. I don't need to reinvent that process, I just need to open IE (silently), load the web page (silently), trigger the EXPORT function that's in a script block in the HEAD of the page (which will open a separate window), then close down IE.

Any thoughts?

Answer:

Depends on the page/site but you can execute javascript functions via the .execscript() method. You basically have to use the window object to do so. You can also do so within FRAMES that have their own javascript functions.

Have you ever automated MSIE ? If so then it goes something like:

msie.document.parentWindow.execScript("javascript:getCPT();")
or if it's inside a frame, you have to define the frame first,then...
LoginFrame.document.parentWindow.execScript("javascript:getCPT();")

Article ID:   W17452
File Created: 2008:04:10:15:10:42
Last Updated: 2008:04:10:15:10:42