|
Script Loader
XML Menu Builder
Build powerful, client-side DHTML menus using XML for data and CSS for style. No JavaScript data! No having to place list elements on every single page of your website! No plug-ins!
Script Loader is a JavaScript script that enables you to dynamically load external JavaScript scripts. Script Loader is compatible with all browsers. Demo This page dynamically loads a script called demo.js. demo.js has a method called showHello. showHello displays an alert box with the text, "Hello, world". Clicking the button below, calls the method showHello. Download Script Loader Script Loader is an external script. An example of calling the script is included in the download. Download script_loader.zip Method: function loadScript(url) Parameters url:
Absolute or relative URL of external JavaScript script
to load.
Example Usage The example below loads the external script, demo.js. Because the parameter to loadScript is given as a relative URL, it is assumed that demo.js is located in the same directory as the web page. loadScript("demo.js"); If we wanted to specify the parameter to loadScript as an absolute URL, we could use the following syntax: loadScript("http://codehouse.com/javascript/scripts/script_loader/demo.js"); Specifying the external script as an absolute URL allows you to load the script from any web page. Restrictions Calls to loadScript should only be made within the head or body tag pairs, while the page is being loaded. loadScript should not be called after the page is loaded. This is because adding a script tag to the document after it has already been created will corrupt the markup. Accordingly, do not call loadScript() from an onload handler, or any other type of event handler. You should wait for the page to load before accessing data/methods inside of a dynamically loaded script, as scripts loaded with loadScript() do not necessarily load synchronously. Accordingly, you should make these calls from within an event handler. Support If you have any questions, find any bugs, or have suggestions, feel free to contact us. |