Return to Snippet

Revision: 47937
at June 18, 2011 20:46 by studioevoque


Initial Code
function loadScript(sScriptSrc, oCallback) {
	var oHead = $('head')[0];
	var oScript = document.createElement('script');
	oScript.type = 'text/javascript';
	oScript.src = sScriptSrc;
	// most browsers
	oScript.onload = oCallback;
	// IE 6 & 7
	oScript.onreadystatechange = function() {
		if (this.readyState == 'complete') {
			oCallback();
		}
	}
	oHead.appendChild(oScript);
}

Initial URL
http://www.ejeliot.com/blog/109

Initial Description
you need jQuery already loaded for this to work

Initial Title
Load a JavaScript file dynamically

Initial Tags
jquery

Initial Language
JavaScript