How to run a javascript function after a specific JS has loaded? -
i have made js function including javascript in html. need make sure script have loaded using function has completed processing , move further in original script.
function loadbackupscript(){ var script = document.createelement('script'); script.src = 'http://www.geoplugin.net/javascript.gp'; script.type = 'text/javascript'; var head = document.getelementsbytagname("head")[0]; head.appendchild(script); }
i need know script has loaded use functions ahead. how do that?
function loadbackupscript(callback) { var script; if (typeof callback !== 'function') { throw new error('not valid callback'); } script = document.createelement('script'); script.onload = callback; script.src = 'http://www.geoplugin.net/javascript.gp'; document.head.appendchild(script); } loadbackupscript(function() { alert('loaded'); });
Comments
Post a Comment