The CreateObject method creates an instance of a COM component with a specified ProgID and, optionally, registers the current script as a handler for events generated by the newly created object.
If the strSubPrefix argument is non-empty, then this method will bind the events of the newly created object to event handlers (sinks) in the currently executing script. After such a call to CreateObject, whenever an event in the newly created object occurs, WSH will look for a subroutine in the currently executing script whose name is the concatenation of strSubPrefix and the name of the event being fired. If this subroutine has the correct prototype to act as an event-handler for the event, then WSH will call it and pass it the appropriate arguments. Note that WSH looks for a subroutine whose name is the direct concatenation of the specified strSubPrefix and the event name - no underscore is included in the name unless it is specified in strSubPrefix.
Set objIE =
WScript.CreateObject("InternetExplorer.Application","objIE_")
objIE.Visible = True
boolBrowserRunning = True
Do While objIE.Visible
WScript.Sleep 500
Loop
Sub objIE_NavigateComplete2(ByVal pDisp, URL)
WScript.Echo "You just navigated to",
URL
End Sub
Sub objIE_OnQuit()
boolBrowserRunning = False
End
SubYou just
navigated to http://www.devguru.com
You just navigated to
http://www.devguru.com/top.html
You just navigated to
http://www.devguru.com/frameset.asp
You just navigated to
http://www.devguru.com/menu.asp
You just navigated to
http://www.devguru.com/home.asp
This VBScript code creates an instance of Internet Explorer and establishes an event handler for its NavigateComplete2 event. When IE is opened, if the user navigates to http://www.devguru.com and then closes the browser, the output shown will be generated.
objIE =
WScript.CreateObject("InternetExplorer.Application","objIE_")
objIE.Visible = true
while (objIE.Visible)
{
WScript.Sleep(500)
}
function objIE_NavigateComplete2(pDisp, URL)
{
WScript.Echo("You just navigated
to", URL)
}
function objIE_OnQuit()
{
boolBrowserRunning = false ;
}You just
navigated to http://www.devguru.com
You just navigated to
http://www.devguru.com/top.html
You just navigated to
http://www.devguru.com/frameset.asp
You just navigated to
http://www.devguru.com/menu.asp
You just navigated to
http://www.devguru.com/home.asp.This JScript code creates an instance of Internet Explorer and establishes an event handler for its NavigateComplete2 event. When IE is opened, if the user navigates to http://www.devguru.com and then closes the browser, the output shown will be generated.