Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

src problems

Status
Not open for further replies.

James1981

Programmer
Nov 2, 2002
76
US
Hi,

I have the following script setup:

Code:
<script language=javascript src=myfile.js>

myVar1 = &quot;test&quot;;

</script>

within myfile.js the script references myVar1, but when i run the script IE says it can't find the variable. Am I doing anything wrong, if so is there a work-a-round?

Cheers
James
 
actually James you aren't doing something wrong per say. It is a quirk about the first implementation of Javascript. When you have a src in your script tag it will ignore everything inside it. The workaround is to have another script tag with no src attribute.

<script language=javascript>
myVar1 = &quot;test&quot;;
</script>

<script language=javascript src=myfile.js></script>

Gary Haran
********************************
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top