Share via


Sys.Application.notifyScriptLoaded Method

Called by a referenced script to indicate that it has been loaded.

Sys.Application.notifyScriptLoaded();

Return Value

None.

Remarks

Call the notifyScriptLoaded method in all file-based scripts (.js files) to indicate to the ScriptManager object that a referenced script has finished loading. The script manager injects script elements into the DOM sequentially, waiting for each script to finish loading before it proceeds to the next one. You must include a call to the notifyScriptLoaded method in each file-based script for pages that perform an asynchronous postback. A call to the notifyScriptLoaded method is the only reliable way to provide notification in all browser types that the script has finished loading.

When calling the notifyScriptLoaded method, it is good practice to check for the presence of the Microsoft AJAX Library to prevent errors if the library is unavailable. The following example shows how to check for the library.

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 

Do not call the notifyScriptLoaded method from scripts that are embedded in assemblies. The script resource handler adds an instance of this call, and a second call will cause an error. If you must embed a file that calls notifyScriptLoaded in an assembly, you can prevent an error by setting the NotifyScriptLoaded property of the ScriptReference object that points to the script to false. (The default is true.) For more information, see the NotifyScriptLoaded property documentation.

See Also

Reference

ScriptReference.NotifyScriptLoaded

Sys.Application Class

Other Resources

Language Reference