Load / Include a javascript from another javascript
Posted: Tue Jan 09, 2007 8:44 am
BB
Regular
Joined: Jun 23, 2004
Posts: 340
Say for example you want to split up your javascript code into multiple files and do not want to alter the original page. Here is a function called include_dom which will enable you to do just that.
Code:
function include_dom(script_filename) {
var html_doc = document.getElementsByTagName('head').item(0);
var js = document.createElement('script');
js.setAttribute('language', 'javascript');
js.setAttribute('type', 'text/javascript');
js.setAttribute('src', script_filename);
html_doc.appendChild(js);
return false;
}
Here is a nice article with the details. Note that in the above example, the ProdHash.js uses functions in the Hashtable.js, so you need to call them in order.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest (c) 2006 by Group29 Productions.
You can syndicate Group29 Productions news with an RSS Feeder using the file backend.php