Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

Q399 How can I use a variable to dictate which *.js source file is loaded?

irt.org | Knowledge Base | JavaScript | Source | Q399 [ previous next ]

Q399 How can I use a variable to dictate which *.js source file is loaded?

In Netscape you can use JavaScript entities:

<script language="JavaScript"><!--
var file = "filename.js";
//--></script>
  
<script src="&{file};" language="Javascript1.1"></script>

However, Internet Explorer does not support JavaScript entities, which is what &{file}; is.

Try instead:

<script language="JavaScript"><!--
var file = "filename.js";
//--></script>

<script language="JavaScript"><!--
document.write('<script src="' + file + '"><\/script>');
//--></script>

Feedback on 'Q399 How can I use a variable to dictate which *.js source file is loaded?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.