Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

External .js files again

 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, for some reason, when I include the LOC

inside my header script tag, the HTML page doesnt work correctly,
even though external.js file is blank.
Some of the page shows up, like the tables, but the
tables' cells aren't shown.

What I've now just done is use 2 header scripts, the first one uses
src="external.js", and the second doesn't, and it all functions correctly
again.

I'm unclear what is happening here, is it mandatory that functions
'imported' from external .js files be included in scripts separate
from the original scripts in a html page?

Thanks for any advice.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you closing the tag

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

the XHTML /> does not work with IE.

The js file should not include opening and closing <script> tags

Eric
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Basically, when I use...


it doesn't work right, and the tables cells are empty.

But... when I use...

There is no problem. I'm confused why the first code doesn't work
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you specify the src attribute to the script tag, the body of the script tag is ignored.

So don't mix and match them.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65218
95
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the HTML 4 spec:

The script may be defined within the contents of the SCRIPT element or in an external file. If the src attribute is not set, user agents must interpret the contents of the element as the script. If the src has a URI value, user agents must ignore the element's contents and retrieve the script via the URI. Note that the charset attribute refers to the character encoding of the script designated by the src attribute; it does not concern the content of the SCRIPT element.

[ February 26, 2006: Message edited by: Bear Bibeault ]
 
colin shuker
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So have I done that the correct way in the second piece of code, in my last post?
It seems wrong using scripts like that, so if I wanted to use functions from say external1.js and external2.js, as well as functions in the html
page, would I use...


Thanks again for your help
[ February 26, 2006: Message edited by: colin shuker ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic