WSH » WScript » DisconnectObject

Syntax:
WScript.DisconnectObject (objObject)
objObject
Receives a handle to the object that will be disconnected from any event-handling.

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.

Examples

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

This 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.

Language(s): JavaScript

See Also: