473,804 Members | 2,249 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

langua= vs type=

xah
what's the pro and con of using

<script language="javas cript">
vs
<script type="text/javascript">

Xah
xa*@xahlee.org
http://xahlee.org/

Aug 27 '05 #1
31 2607


xa*@xahlee.org wrote:
what's the pro and con of using

<script language="javas cript">
vs
<script type="text/javascript">


Originally when browser vendors invented the <script> element they gave
it a language attribute where the value could be anything.

Those standardizing HTML did not like that attribute but rather
preferred to introduce the type attribute which is supposed to take a
standardized content type value:
<http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1>
Ironically until recently text/javascript as a content type was nowhere
standardized.

By now you can simply use
<script type="text/javascript">
browsers around understand that and you write valid HTML 4 that way if
you care or other judging your HTML care.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Aug 27 '05 #2
<xa*@xahlee.org > wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
what's the pro and con of using

<script language="javas cript">
vs
<script type="text/javascript">
I'd use both, personally.

The latter is standardized and recommended while the former is deprecated...
but the former still has the best support and is still the cleanest way to
specify the version of the language needed for the script.

For example using : <script language="JavaS cript1.5"> will prevent your
script from running on
most older browsers.

It really annoys me when the W3C replacement technologies don't address all
the features of the thing they're replacing. ;^)

Jim Davis
Aug 27 '05 #3
"Jim Davis" <ne********@vbo ston.com> writes:
<script language="javas cript">
vs
<script type="text/javascript">
I'd use both, personally.

The latter is standardized and recommended while the former is deprecated...
.... and required for validating HTML, not to forget.
but the former still has the best support
Can you find any browser that accepts <script language="javas cript"> but
doesn't treat <script type="text/javascript"> exactly the same?
and is still the cleanest way to specify the version of the language
needed for the script.
The version of "JavaScript " that you need, but only Netscape and Mozilla
uses JavaScript as the language. IE uses JScript and other browsers use
their own version of ECMAScript.
For example using : <script language="JavaS cript1.5"> will prevent your
script from running on most older browsers.


That might be useful if your script contains new syntax not available
in earlier versions, but otherwise you should use feature detection
instead. It degrades much cleaner.

Also, at least one version of JavaScript had different semantics for
the same code, compared to later (and earlier) versions. Specifiying
that version, i.e., <script language="javas cript1.2">, will make
some browsers use JS1.2 semantics and other browsers use current version
semantics, so the same program works differently *because* the language
version is specified.

I recommend only using the type attribute and using feature detection
for differences between different browsers. There are far more browsers
than there are JavaScript versions.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Aug 27 '05 #4
xah
> <script language="javas cript"> vs <script type="text/javascript">
The latter is standardized and recommended while the former is deprecated....
but the former still has the best support and is still the cleanest way to
specify the version of the language needed for the script.
very good point. A look over the major sites shows that:

amazon.com uses both and sometimes just the language=.

applec.om uses just the language=.
yahoo.com uses just the language=.
orkut.com uses just the type=.

msn.com sometimes uses both, sometimes one or the other.
ebay same with msn.com.

so far it seems the language= is more popular...

Those using language= does not always indicate a version.

one wonders if there is a pattern for sites that uses both sometimes
one of the other.
my guess is that it's rather random...

oh, the story of the industry....

Xah
xa*@xahlee.org
http://xahlee.org/

Jim Davis wrote: <xa*@xahlee.org > wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.com.. .
what's the pro and con of using

<script language="javas cript">
vs
<script type="text/javascript">
I'd use both, personally.

The latter is standardized and recommended while the former is deprecated....
but the former still has the best support and is still the cleanest way to
specify the version of the language needed for the script.

For example using : <script language="JavaS cript1.5"> will prevent your
script from running on
most older browsers.

It really annoys me when the W3C replacement technologies don't address all
the features of the thing they're replacing. ;^)

Jim Davis


Aug 27 '05 #5
xah

x...@xahlee.org wrote:
A look over the major sites shows that:

amazon.com uses both and sometimes just the language=.

applec.om uses just the language=.
yahoo.com uses just the language=.
orkut.com uses just the type=.

msn.com sometimes uses both, sometimes one or the other.
ebay same with msn.com.


google.com simply uses <script> period, way ahead of the pack!

Xah
xa*@xahlee.org
http://xahlee.org/

Aug 27 '05 #6
"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:ac******** **@hotpop.com.. .
"Jim Davis" <ne********@vbo ston.com> writes:
<script language="javas cript">
vs
<script type="text/javascript">
I'd use both, personally.

The latter is standardized and recommended while the former is
deprecated...
... and required for validating HTML, not to forget.
but the former still has the best support


Can you find any browser that accepts <script language="javas cript"> but
doesn't treat <script type="text/javascript"> exactly the same?


Yes - all of them. The former can specific version while the latter
cannot - this is a difference. Also, there is really nothing to do with the
type="text/javascript" - can you give me an exmaple of how a browser that
supports the src attribute but doesn't support the type attribute would
behave differently from one that supports both?
and is still the cleanest way to specify the version of the language
needed for the script.


The version of "JavaScript " that you need, but only Netscape and Mozilla
uses JavaScript as the language. IE uses JScript and other browsers use
their own version of ECMAScript.


While that's true in a sense it's not in practice. JScript (and other
browser implementations ) are ECMAScript complaint - so they happily accept
"JavaScript 1.3" (for example) as a language attribute. The marketing name
of the implementation doesn't affect it compatibility with the standard
name.
For example using : <script language="JavaS cript1.5"> will prevent your
script from running on most older browsers.


That might be useful if your script contains new syntax not available
in earlier versions, but otherwise you should use feature detection
instead. It degrades much cleaner.


True - I agree completely. But often it's unclear what features to detect.
;^)

Noplace did I say (or will I ever say) that you should use this as your only
validation of capability. But it is a very good "front line" which gives
you a basic level of understanding.
Also, at least one version of JavaScript had different semantics for
the same code, compared to later (and earlier) versions. Specifiying
that version, i.e., <script language="javas cript1.2">, will make
some browsers use JS1.2 semantics and other browsers use current version
semantics, so the same program works differently *because* the language
version is specified.


Exactly (the browser you're thinking of is Netscape 2.0) which is why, in
general, I recommend using "JavaScript 1.3" as the language attribute.
You're code won't run on Netscape 2.0 but neither will you have to deal with
it's broken implementation.

Jim Davis
Aug 27 '05 #7
<xa*@xahlee.org > kirjoitti
viestiss:11*** *************** ****@g49g2000cw a.googlegroups. com...
<script language="javas cript"> vs <script type="text/javascript">
The latter is standardized and recommended while the former is
deprecated...
but the former still has the best support and is still the cleanest way
to
specify the version of the language needed for the script.


very good point. A look over the major sites shows that:


What does major sites have to do with writing valid markup? Nothing. Just
because a site has lot of hits, doesn't automatically say that the code is
valid. In fact, like in Google's case, the code may be complete crap. Just
try running google.com through a w3c validator - doesn't avalidate, man.
Instead you need to look at w3c specs what they have to say about it and do
it like that.

Major sites are not standards, standards are standards. w3c.org has listed
those standards and specifications for html markup, xhtml or css, etc.
Regardless of what major sites do, you need to do like the standards say,
not like major sites do it.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.ber keley.edu/>
Kimmo Laine <et************ ****@5P4Mgmail. com>
Aug 27 '05 #8
<xa*@xahlee.org > kirjoitti
viestiss:11*** *************** ****@g49g2000cw a.googlegroups. com...
amazon.com uses both and sometimes just the language=.
http://validator.w3.org/check?verbos...819246-3276165
Cannot even begin to check code, because the charset is already fucked.
applec.om uses just the language=.
Assuming you meant apple.com?
http://validator.w3.org/check?verbos...www.apple.com/
-> Not valid. One of the errors: required attribute "TYPE" not specified in
<SCRIPT>
yahoo.com uses just the language=.

http://validator.w3.org/check?verbos...www.yahoo.com/
-> Not valid (failed with unbelievable 266 errors.) Once again one of the
errors: required attribute "TYPE" not specified in <SCRIPT>, but there's
just so many things wrong with the page that one can but wonder, how the do
these pages work at all, unless the browsers have great tolerance for
errors.
orkut.com uses just the type=.
http://validator.w3.org/check?verbos...com/Login.aspx
-> Not valid. One of the errors: required attribute "TYPE" not specified in
<SCRIPT>
msn.com sometimes uses both, sometimes one or the other.
ebay same with msn.com.


http://validator.w3.org/check?verbos...//www.msn.com/
-> Not valid. Tries to be xhtml, but fails! Hah! And here's the thing:
there is no attribute "language" and required attribute "type" not
specified:
<script language="JavaS cript">

And in your follow-up you refered to google.com:
http://validator.w3.org/check?verbos...ww.google.com/
-> Not valid. One of the errors: required attribute "TYPE" not specified in
<script>
In conclusion: in html 4.01 "type" is required in <script> and when moving
to xhtml, language is no more allowed. Need I say more?

Lesson we learned today, kids, is that never ever look at major sites code
and assume it's correct. Not one single site of what you suggested were
valid according to w3c validator.

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.ber keley.edu/>
Kimmo Laine <et************ ****@5P4Mgmail. com>
Aug 27 '05 #9
xa*@xahlee.org wrote:
what's the pro and con of using

<script language="javas cript">
vs
<script type="text/javascript">


Use
<script type="text/javascript">

http://www.w3.org/TR/html401/interac....html#h-18.2.1

It's the only way to get standards compliant HTML.

Although the language parameter allows you to detect the version, it is
actually much easier to use feature detection instead of having to
figure out which feature is in which version. And it would not surprise
me if browser think different about what is in which version.

The fact that most website use the language parameter (too) is no reason
to do it like that too. Most people do not know or care about web
standards and other browsers than IE.
Aug 27 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
13173
by: Danny Pressley | last post by:
I have a VS.NET 2003 Visual C++ MFC Application Project in which I added a new resource file, I then added an icon to this new resource file and did a rebuild and got the following error: "fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409". But the resource ID is unique and only located in the new Resource1.h and MyResourceFile.rc files. Any ideas why this error is occuring? To generate the issue real quick, you...
6
2694
by: S.Tobias | last post by:
I'm trying to understand how structure type completion works. # A structure or union type of unknown # content (as described in 6.7.2.3) is an incomplete type. It # is completed, for all declarations of that type, by ^^^ # declaring the same structure or union tag with its defining # content later in the same scope. ^^^^^ (6.2.5#23)
0
1778
by: Chris Fink | last post by:
When I am consuming a webservice, an object has an undefined value (inq3Type.Call3Data). I do not completely understand why this is happening and apologize for the vague question. My assumption is that the WSDL is defined incorrectly and .NET cannot parse the types. Any help is greatly appreciated! CustDDGSvc ws = new CustDDGSvc(); ws.Url = "http://dmapfra003.decisionone.com:8080/JISOAP/CustDDGSvc"; // don't understand why the...
1
8713
by: Rob Griffiths | last post by:
Can anyone explain to me the difference between an element type and a component type? In the java literature, arrays are said to have component types, whereas collections from the Collections Framework are said to have an element type. http://java.sun.com/docs/books/jls/second_edition/html/arrays.doc.html
669
26274
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
3
2830
by: john | last post by:
Hi to All To demonstrate: public class MyBaseGenericClass<T> { } public class MyGenericClass1<T: MyBaseGenericClass<T> {
7
7821
by: Sky | last post by:
I have been looking for a more powerful version of GetType(string) that will find the Type no matter what, and will work even if only supplied "{TypeName}", not the full "{TypeName},{AssemblyName}" As far as I know yet -- hence this question -- there is no 'one solution fits all', but instead there are several parts that have to be put together to check. What I have so far is, and would like as much feedback as possible to ensure I've...
9
3881
by: weirdwoolly | last post by:
Hopefully someone will be able to help. I have written a stored procedure in C++ called from a Java test harness to validate the graphic data types in C++ and their use. I have declared the vargraphic input parameters along the following lines in i_vargraphic100 vargraphic(100) and they are populated from String's in java.
5
3179
by: JH | last post by:
Hi I found that a type/class are both a subclass and a instance of base type "object". It conflicts to my understanding that: 1.) a type/class object is created from class statement 2.) a instance is created by "calling" a class object.
0
10599
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10346
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10347
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9173
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7635
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6863
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5531
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4308
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3832
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.