...

View Full Version : Include js file inside js file



gemguy
07-13-2007, 10:47 AM
Hi

I have two .js files namely js1 and js.2. I want to include js1 file within js2 file. Is it possible. I tried with document.write("<script src="abc.js">.....</script>"). Let me have any solutions

Bill Posters
07-13-2007, 11:16 AM
Rather than 'including' js1 file within js2, you can use scripting within js2 to add js1 to the document.

e.g.

js2.js

var js1 = document.createElement('script');
js1.type = 'text/javascript';
js1.src = 'js1.js';

var headEl = document.getElementsByTagName('head')[0];
headEl.appendChild(js1);



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum