• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

External .js files again

 
Ranch Hand
Posts: 750
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 67756
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic