Dyamic Script Loading
Dynamic Script Loading means inserting "" to a HTML and let the browser to load a script dynamically. This is the only way to dynamically load javascript if the script is located in a domain that is different from the HTML domain. ( If the HTML and the javascript were located in the same domain, you could read the script using ajax and execute it by the eval function. )
==========================================================================================
[Basic procedure]
==========================================================================================
(1) First, create div for a place to insert scripts:
(2) Then insert "";
$( '#script_div' ).html( s );
==========================================================================================
[Compatibility]
==========================================================================================
==============================
IE
==============================
Works in IE6
-----------------------------------------------
Name: Internet Explorer 6.0 (Full Installer)
File Size: 76.74 MB
Date Released: 27 August, 2001 (10 years ago)
-----------------------------------------------
==============================
FireFox
==============================
Works in FF2.0
-----------------------------------------------
Name: Firefox 2.0.0.20
File Size: 5.77 MB
Date Released: 18 December, 2008 (3 years ago)
-----------------------------------------------
==============================
Chrome
==============================
Works in Chrome3.0
-----------------------------------------------
Name: Google Chrome 3.0.182
File Size: 9.87 MB
Date Released: 13 July, 2009 (2 years ago)
-----------------------------------------------
==============================
Safari
==============================
v3.2 Problem
When the script is generated dynamically, the scope of the script is not global.
For example, consider the following two "
"
In other browsers, alert(a) should show "100" but Safari3.2 returns "unknown"
This problem was fixed in Safari 4.0
-----------------------------------------------
Name: Safari 3.2
File Size: 19.69 MB
Date Released: 14 November, 2008 (3 years ago)
-----------------------------------------------
Name: Safari 4.0
File Size: 27.15 MB
Date Released: 18 June, 2009 (2 years ago)
-----------------------------------------------
==============================
Opera
==============================
Opera 8.0 does not execute