Method:  WScript.DisconnectObject

WScript.DisconnectObject objObject

The DisconnectObject method disconnects any event-handling connection between the currently executing script and the specified object. If a connection with the specified object was not previously established with a call to ConnectObject, CreateObject or GetObject, then this method does nothing.

The following JScript code creates an instance of Internet Explorer and establishes an event handler for its NavigateComplete2 event. The script handles this event for 30 seconds and then disconnects from the Internet Explorer object. If the user navigates to http://www.devguru.com during this 30 second period, they will see the output shown.

Code:
objIE = WScript.CreateObject("InternetExplorer.Application","objIE_")
objIE.Visible = true

WScript.Sleep(30000)
WScript.DisconnectObject(objIE)

function objIE_NavigateComplete2(pDisp, URL)
{
    WScript.Echo("You just navigated to", URL)
}


Output:
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

Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information