RemoveStartupScript Method  
 

Removes a script which was previously added to the specified browser instance.

Syntax

object.RemoveStartupScript ( ScriptId )

Parameters

ScriptId
An integer which identifies the script to be removed. This value cannot be zero.

Return Value

Returns True if the script was removed. If the script identifier is invalid or the script could not be removed, the method returns False.

Remarks

The RemoveStartupScript method removes a previously registered startup script from the specified browser instance. The ScriptId parameter must contain the nonzero script identifier returned by a successful call to the AddStartupScript method. Script identifiers are associated with a specific browser instance and cannot be used to remove scripts registered with another instance.

Removing a startup script prevents it from being executed when subsequent documents are loaded. It does not undo any changes made by the script to the currently loaded document, nor does it remove JavaScript variables, methods, or other objects that were created when the script was previously executed. These changes remain in effect until the document is unloaded or they are explicitly modified by other JavaScript code.

If navigation is already in progress when a startup script is removed, the script may still execute as part of that navigation. Applications should remove startup scripts before initiating navigation when it is important to ensure the scripts are not executed.

A startup script can be removed at any time after it has been successfully registered. Once removed, its identifier is no longer valid and should not be used again. To execute the same script during subsequent navigations, it must be registered again using the AddStartupScript method, which will return a new script identifier.

Removing a startup script does not affect other scripts registered with the browser instance or JavaScript code that is part of the loaded document.

See Also