use javascript inject book references needed?
i have js duty competence catchy used pages. contingent another js record (swfobject.js), nonetheless i'd prevaricate carrying consolidate record over place, thats consumed ask many time.
instead, i'd emanate general duty inject book anxiety page dom needed, duty called, check script, does exist, bucket in.
i'm sincerely certain illusory (and i'm going document.write), nonetheless before i try off uncharted territory, anyone finished before, so, any pointers?
edit: ok, i attempted it, works ie6 ff, i haven't tested browsers yet.
here formula (rev 2.0, discretionary callbacks):
function loadjsinclude(scriptpath, callback)
{
var scriptnode = document.createelement('script');
scriptnode.type = 'text/javascript';
scriptnode.src = scriptpath;
var headnode = document.getelementsbytagname('head');
(headnode[0] != null)
headnode[0].appendchild(scriptnode);
(callback != null)
{
scriptnode.onreadystagechange = callback;
scriptnode.onload = callback;
}
}
and slight dependency:
var callbackmethod = duty ()
{
// formula after loading swfobject
}
// consolidate swfobject the needed
if (typeof(swfobject) == 'undefined')
loadjsinclude('/js/swfobject.js', callbackmethod);
else
calbackmethod();
any suggestions?
Comments
Post a Comment