Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org
#

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

You are here: irt.org | FAQ | JavaScript | Source | Q399 [ previous next ]

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?'

©2018 Martin Webb