CWebView::RemoveStartupScript Method  
 
BOOL RemoveStartupScript(
  DWORD dwScriptId  
);

The RemoveStartupScript method removes a script which was previously added to the specified browser instance.

Parameters

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

Return Value

If the method succeeds, the return value is non-zero. If the method fails, the return value is zero. To get extended error information, call the GetLastError method.

Remarks

The RemoveStartupScript method removes a previously registered startup script from the specified browser instance. The dwScriptId 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.

Requirements

Minimum Desktop Platform: Windows 7 Service Pack 1
Minimum Server Platform: Windows Server 2008 R2 Service Pack 1
Header File: cstools12.h
Import Library: cshtmv12.lib

See Also