Javascript Loader
11
This script will allow for conditional loading of javascript libraries. The example here only has one condition to check for IE or Firefox then loads the appropriate .js file.
This is part of an .aspx template for an educational portal product.
Usage for loading the script:
This is part of an .aspx template for an educational portal product.
Usage for loading the script:
// Core functions for Blackbird Template
// written by Jeremy Edmiston (jeremyedmiston@pointloma.edu)
// The functions have been adapted from various sources
// and re-written to provide maximum flexibility
// and compatability with various browsers.
//Global Declarations
var ie = (document.all) ? true : false;
var scriptPath = templatePath + 'scripts/';
var stylePath = templatePath + 'styles/';
var imagePath = templatePath + 'images/';
// Detect Browser and load appropriate scripts
if(ie){loadJS('ie.js')}else{loadJS('ff.js')}
function loadJS(scriptName) {
var head = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language','javascript');
js.setAttribute('type','text/javascript');
if (scriptName.indexOf("/")== -1) {
js.setAttribute('src', scriptPath + scriptName);
}else{
js.setAttribute('src', scriptName);
}
js.setAttribute('id',scriptName);
js.setAttribute('defer','true');
if (ie){
document.write('<script language=' + js.language + ' type=' + js.type + ' src=' + js.src + ' id=' + js.id + ' ></script>');
}else{
head.appendChild(js);
}
}
Comments
Voting
Votes Up
ashraf_eme
ColdKeyboard
dannyboy
HRCerqueira
i_kenneth
napyfab
Pio
SecondV
Sonsam
sundaramkumar
wiz1705






There are currently no comments for this snippet.