Sign In | Register Now About Bytes | Help | Site Map
Connecting Tech Pros Worldwide

<script language="javascript" ..is correct in xhtml?

Question posted by: howa (Guest) on June 27th, 2008 07:16 PM
Just found a funny things..

in HTML4's dtd, http://www.w3.org/TR/html4/strict.dtd

language is not valid, i.e.

<!ELEMENT SCRIPT - - %Script; -- script statements -->
<!ATTLIST SCRIPT
charset %Charset; #IMPLIED -- char encoding of linked
resource --
type %ContentType; #REQUIRED -- content type of script
language --
src %URI; #IMPLIED -- URI for an external script
--
defer (defer) #IMPLIED -- UA may defer execution of
script --
event CDATA #IMPLIED -- reserved for possible future
use --
for %URI; #IMPLIED -- reserved for possible future
use --
Quote:
>


But in XHTML, language is valid (although type is still required)


http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

<!ELEMENT script (#PCDATA)>
<!ATTLIST script
id ID #IMPLIED
charset %Charset; #IMPLIED
type %ContentType; #REQUIRED
language CDATA #IMPLIED
src %URI; #IMPLIED
defer (defer) #IMPLIED
xml:space (preserve) #FIXED 'preserve'
Quote:
>


Howard.

C A Upsdell's Avatar
C A Upsdell
Guest
n/a Posts
June 27th, 2008
07:16 PM
#2

Re: <script language="javascript" ..is correct in xhtml?
howa wrote:
Quote:
Just found a funny things..
>
in HTML4's dtd, http://www.w3.org/TR/html4/strict.dtd
>
language is not valid, i.e.


You're comparing apples and oranges: strict and transitional.

howa's Avatar
howa
Guest
n/a Posts
June 27th, 2008
07:16 PM
#3

Re: <script language="javascript" ..is correct in xhtml?
On Jun 5, 1:19 am, C A Upsdell <cupsd...@upsdell.invalidwrote:
Quote:
howa wrote:
Quote:
Just found a funny things..

>

>
Quote:
language is not valid, i.e.

>
You're comparing apples and oranges: strict and transitional.


Oh...I have misread that!

So change the topic:

Why language is allowed in transitional, but not strict ?


Howard

Rik Wasmus's Avatar
Rik Wasmus
Guest
n/a Posts
June 27th, 2008
07:16 PM
#4

Re: <script language="javascript" ..is correct in xhtml?
On Wed, 04 Jun 2008 19:31:34 +0200, howa <howachen@gmail.comwrote:
Quote:
On Jun 5, 1:19 am, C A Upsdell <cupsd...@upsdell.invalidwrote:
Quote:
>howa wrote:
Quote:
Just found a funny things..

>>

>>
Quote:
language is not valid, i.e.

>>
>You're comparing apples and oranges: strict and transitional.

>
Oh...I have misread that!
>
So change the topic:
>
Why language is allowed in transitional, but not strict ?


Because it's deprecated, so it will be in many old documents, and while
TRANSITIONING to a new DTD/version, it can be many of them are still not
'caught'/altered. The moment of complete compliance, as soon as you're
done transitioning, you also have replaced all the language attributes
with type-attributes, and you can use STRICT. Using transitional for html
not transitioning is just silly...
--
Rik Wasmus
....spamrun finished

howa's Avatar
howa
Guest
n/a Posts
June 27th, 2008
07:16 PM
#5

Re: <script language="javascript" ..is correct in xhtml?
Hi
Quote:
Because it's deprecated, so it will be in many old documents, and while
TRANSITIONING to a new DTD/version, it can be many of them are still not
'caught'/altered. The moment of complete compliance, as soon as you're
done transitioning, you also have replaced all the language attributes
with type-attributes, and you can use STRICT. Using transitional for html
not transitioning is just silly...
--
Rik Wasmus
...spamrun finished


Interesting questions would be

1. Who created it? Why removed finally?
2. `type` is required even at HTML4 dtd, why people are only using
`language`? (Due to incorrect implementation of Dreamweaver /
Frontpage for example?)

Howard

C A Upsdell's Avatar
C A Upsdell
Guest
n/a Posts
June 27th, 2008
07:16 PM
#6

Re: <script language="javascript" ..is correct in xhtml?
howa wrote:
Quote:
Quote:
>Because it's deprecated, so it will be in many old documents, and while
>TRANSITIONING to a new DTD/version, it can be many of them are still not
>'caught'/altered. The moment of complete compliance, as soon as you're
>done transitioning, you also have replaced all the language attributes
>with type-attributes, and you can use STRICT. Using transitional for html
>not transitioning is just silly...
>--
>Rik Wasmus
>...spamrun finished

>
Interesting questions would be
>
1. Who created it? Why removed finally?
2. `type` is required even at HTML4 dtd, why people are only using
`language`? (Due to incorrect implementation of Dreamweaver /
Frontpage for example?)


Netscape 4 did not support TYPE, so LANGUAGE had to be used until
Netscape 4 became extinct, and even when it had become extinct, many
people continued to use LANGUAGE, perhaps out of habit.




Jukka K. Korpela's Avatar
Jukka K. Korpela
Guest
n/a Posts
June 27th, 2008
07:16 PM
#7

Re: <script language="javascript" ..is correct in xhtml?
Scripsit C A Upsdell:
Quote:
Netscape 4 did not support TYPE, so LANGUAGE had to be used until
Netscape 4 became extinct


Since Netscape only supported JavaScript as the scripting language, no
attribute was needed to tell it that the language is JavaScript.

The LANGUAGE attribute was introduced by Netscape to indicate JavaScript
_version_, and if you wish to do that, you still need that attribute,
since the TYPE attribute does not allow that. (More exactly, the
Internet media types for JavaScript do not allow any version to be
specified.)

It was (and still is) possible to write e.g. one SCRIPT element with
LANGUAGE="JavaScript1.2" and another one with LANGUAGE="JavaScript1.3"
so that a browser that only supports JavaScript 1.2 ignores the latter.
This was never a particularly good idea, but that's the story behind
LANGUAGE.

In practice, neither TYPE nor LANGUAGE is needed, since browsers assume
by default that the language is JavaScript. But if you do specify one of
those attributes and with a _wrong_ (e.g., misspelled) value, your
script may well be ignored.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


howa's Avatar
howa
Guest
n/a Posts
June 27th, 2008
07:16 PM
#8

Re: <script language="javascript" ..is correct in xhtml?
On 6$B7n(B5$BF|(B, $B2<8a(B1$B;~(B21$BJ,(B, C A Upsdell <cupsd...@upsdell.invalidwrote:
Quote:
howa wrote:
>
Netscape 4 did not support TYPE, so LANGUAGE had to be used until
Netscape 4 became extinct, and even when it had become extinct, many
people continued to use LANGUAGE, perhaps out of habit.


Definitely a bad habit, even Mozilla don't use LANGUAGE in their web
site now.

Howard

C A Upsdell's Avatar
C A Upsdell
Guest
n/a Posts
June 27th, 2008
07:16 PM
#9

Re: <script language="javascript" ..is correct in xhtml?
Jukka K. Korpela wrote:
Quote:
Scripsit C A Upsdell:
>
Quote:
>Netscape 4 did not support TYPE, so LANGUAGE had to be used until
>Netscape 4 became extinct

>
Since Netscape only supported JavaScript as the scripting language, no
attribute was needed to tell it that the language is JavaScript.


It was actually more complex than that. Netscape 4 was rife with bugs,
some of which appeared in most (or all) versions of Netscape 4, and some
of which appeared only in certain versions. And one of the bugs was
that, when the LANGUAGE attribute was not specified, Netscape would
*sometimes* parse the HTML improperly.

I never did figure out all the factors which led Netscape 4 to misbehave
-- there were SO many -- but I did discover some common factors, and I
developed defensive design techniques which minimized the problems. One
defensive technique was to always include the LANGUAGE attributes. No
doubt there were many cases where it did not matter, but designing
defensively minimized the instances when it did, saving me much time.

 
Not the answer you were looking for? Post your question . . .
189,879 Experts ready to help you find a solution.
Sign up for a free account, or Login (if you're already a member).

Latest Articles: Read & Comment
  • Didn't find the answer you were looking for?
    Post Your Question
  • Top Community Contributors