Download the X Distribution File.
xSmartLoad2(what, url1, url2, url3, etc)
Supports multiple URLs.
// xSmartLoad2 r1, Copyright 2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL
function xSmartLoad2(what, url1, url2, url3, etc)
{
var u, i, j, s, h, loaded, c = 0, e = what.toLowerCase();
if (document.createElement && document.getElementsByTagName) {
h = document.getElementsByTagName('head');
if (h.length && h[0].appendChild) {
for (i = 1; i < arguments.length; ++i) {
loaded = false;
u = arguments[i];
for (j = 0; j < xSmartLoad2.list.length; j++) {
if (xSmartLoad2.list[j] == u) {
loaded = true;
break; // for (j
}
}
if (!loaded) {
s = document.createElement(e);
if (s) {
switch (e) {
case 'script':
s.type = 'text/javascript';
s.src = u;
break;
case 'link':
s.rel = 'stylesheet';
s.type = 'text/css';
s.href = u;
break;
default:
continue; // for (i
}
h[0].appendChild(s);
xSmartLoad2.list[xSmartLoad2.list.length] = u;
++c;
}
}
}
}
}
return c;
}
xSmartLoad2.list = []; // static property of xSmartLoad2
xSmartLoad - Default implementation.
By your use of X and/or CBE and/or any Javascript from this site you consent to the GNU LGPL - please read it. If you have any questions about the license, read the FAQ and/or come to the forums.
Forum support is available at the X Library Support Forums.
Cross-Browser.com is the home of X - a cross-browser Javascript library, and many demos, applications, articles and documentation.
If you are using X, XC or anything from this site, show off your work by posting a link in the X Showcase forum.