Click here to get back home

Does

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Does rhythmace 04-07-2006
|--> Re: Does
Posted by rhythmace on April 7, 2006, 9:05 pm
Please log in for more thread options


W3C HTML validator passes this:

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

<script type="text/javascript">
...script in here...
</script>
...

But as far as I can tell, the first script tag requires a </script>
close tag. Is the close tag required for valid markup? I know browsers
accept this, but that's not the question. Is it valid?


Posted by Eric B. Bednarz on April 7, 2006, 7:39 pm
Please log in for more thread options


rhythmace@gmail.com writes:

> W3C HTML validator passes this:

Here's your SCRIPT element type start tag:

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

Here's some arbitrary CDATA content:

> <script type="text/javascript">
> ...script in here...

Here's your SCRIPT element type end tag:

> </script>

Next time, enable 'view parse tree' (or whatever it is called, I can't
be bothered to have a look).

> But as far as I can tell, the first script tag requires a </script>
> close tag.

Yes. Well, end tag.

> Is the close tag required for valid markup?

Yes.

> I know browsers
> accept this,

Ah. I don't, I have too many of them to make generalised statements
about their treatment of generalized markup.

> but that's not the question. Is it valid?

Yes.


(who cares?)


--
||| hexadecimal EBB
o-o decimal 3771
--oOo--( )--oOo-- octal 7273
205 goodbye binary 111010111011

Posted by Toby Inkster on April 8, 2006, 5:27 am
Please log in for more thread options


rhythmace wrote:

> <script type="text/javascript" src="foo.js">
>
> <script type="text/javascript">
> ...script in here...
> </script>
> ...
>
> But as far as I can tell, the first script tag requires a </script>
> close tag. Is the close tag required for valid markup?

Yes -- the SCRIPT element requires an end tag. But you have an end tag
there.

The real question, is "how many SCRIPT elements do you have there?" The
answer is one.

The second "<script..." bit will be treated as Javascript data within the
first SCRIPT element, and should cause a Javascript error (but not a
validation error).

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact


Posted by VK on April 8, 2006, 8:46 am
Please log in for more thread options



rhythmace@gmail.com wrote:
> <script type="text/javascript" src="foo.js">
>
> <script type="text/javascript">
> ...script in here...
> </script>

That was already explained why such script declaration will not work.
I'd just like to alert you about another common mistake of this kind:

<script type="text/javascript" src="foo.js">
// code here
</script>

// code here block will be ignored and only foo.js code will be
executed (unless it's Netscape 2.x w/o src attribute support)

So the rule is: external file requires separate <script> block with
closing tag.

The only working option:

<script type="text/javascript" src="foo.js"></script>
<script type="text/javascript">
// code here
</script>


Posted by rhythmace on April 8, 2006, 4:54 pm
Please log in for more thread options


Excellent! Thanks so much guys. Actually the browsers appear to be
smart about this and afaict they do interpret 2 script tags, not 1, so
they might have some heuristic. For example, if it is not possible to
nest script tags then maybe they just autoclose the first one???


Similar ThreadsPosted
Does January 4, 2006, 11:46 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap