Javascript include – tricks

Posted by Script kiddie on Jul 11, 2012 in Programming |

You can include a javascript like this:

function include(filename)
var head = document.getElementsByTagName('head')[0];
 script = document.createElement('script');
 script.src = filename; 
script.type = 'text/javascript';

Read more here:

Or even better:
You can easily read another JS-file inside the javascript using jquery:

$.getScript("my_lovely_script.js", function(){
    alert("Script loaded and executed.");    
  // here you can use anything you defined in the loaded script 

Read here:


Copyright © 2020 Web developer & geek blog All rights reserved. Theme by Laptop Geek.