mardi 4 août 2015

How to execute javascript function after js library finished downloading?

So i have the following code in index.html, and i got it from google's developer site, but now i need to run the function mapsResume() after the google maps api library finishes downloading.

function downloadJSAtOnload() {
  var element = document.createElement("script");
  element.src = "http://ift.tt/1ndfcG6";
  document.body.appendChild(element);
  mapsResume();
}

mapsResume(){
/* lots of code */
}

if (window.addEventListener)
   window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
   window.attachEvent("onload", downloadJSAtOnload);
else window.onload = downloadJSAtOnload;




Aucun commentaire:

Enregistrer un commentaire