Passing variable to external js file?

I need real help with this one guys!

I have the following code for my users to place on their site, which displays some HTML from an external js file:

<SCRIPT LANGUAGE="javascript1.1" src="http://xnames.homepagenames.com/xnames2.js"></SCRIPT>

That is all fine and very simple, but…

I need to tell the js file to add a variable at certain places in the HTML code it creates. And that variable needs to be passed from the code above.

I tried the following, but that didn’t work:

<SCRIPT LANGUAGE="javascript1.1" SRC="http://xnames.homepagenames.com/xnames.js">
var affid = "joelmoss";
</script>

Can someone please help?

Define your variable in a separate script block before you call the external file…


<script language="javascript1.1">
var affid = "joelmoss";
</script>
<script language="javascript1.1" src="http://xnames.homepagenames.com/xnames.js">
//external file
</script>

Thanks, that works a treat!

Quick common-sense note on “why” (re: above)…

The browsers parse more or less top down, so it only makes sense that you’d need to create and set the variable before you call the script that uses it.