Posted By

Zufolek on 07/19/09


Tagged


Versions (?)

Dynamically load javascript .js file


 / Published in: JavaScript
 

addjs("monkey"); will load "monkey.js" file in the same directory.

  1. var d=document;
  2.  
  3. function gebt(s){return d.getElementsByTagName(s)}
  4.  
  5. function addjs(s){
  6. var e=d.createElement("script");
  7. e.src=s+".js";
  8. e.s=s;
  9. e.type="text/javascript";
  10. gebt("head")[0].appendChild(e);
  11. }

Report this snippet  

You need to login to post a comment.