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

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -