Welcome to WebmasterWorld Guest from 35.175.191.168

Forum Moderators: open

Message Too Old, No Replies

Executing external javascript

from within javascript

     
7:47 am on Nov 18, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:423
votes: 0


Hello javascripters! My first post in Javascript :)

I have a call in my header to an external script which looks like this (and works!)

<script type="text/javascript" language="JavaScript" src="test.js"></script>

Now I want to make it conditional like this

<script type="text/javascript" language="JavaScript">
if something
do this

else if another something
do this

else //if all else
execute test.js

</script>

Everything works fine but I can't seem to find the correct syntax to get test.js to execute.

7:58 am on Nov 18, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:June 27, 2002
posts:959
votes: 0


Have you tried this?

<script type="text/javascript" language="JavaScript">
if something
do this

else if another something
do this

else //if all else
document.write("<script type=\"text\/javascript\" language=\"JavaScript\" src=\"test.js\"><\/script>");

</script>

8:27 am on Nov 18, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:423
votes: 0


Thank you very much Sinner_G it works just fine :)