473,491 Members | 2,008 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Use of type and/or language in script-tag

Hi group,

I am a bit cconfused with the different tags I encounter to start a script.
I used to use: language="Javascript"

Nowadays I use: type="text/javascript"

I did see some javascript1.2 (i think) too, but never used that.

But when I let my favorite editor (Eclipse) do some codecompletion I get:
<script language="JavaScript" type="text/javascript"
src="jsfile.js"></script>

Forget about the src for a moment.
I see 2 definition in the same tag.

Is that ok?
And on a sidenote: Am I safe when I use the modern type="text/javascript"
only? The answer probably depends on the browser.

Where can I find some coherent information?
Some overview with browsers and javascripttags and such.

I did find some information already but I am looking for a overview/advise.

Thanks for your time!

Regards,
Erwin Moller
Jul 20 '05 #1
7 1868


Erwin Moller wrote:
I am a bit cconfused with the different tags I encounter to start a script.
I used to use: language="Javascript"

Nowadays I use: type="text/javascript"

I did see some javascript1.2 (i think) too, but never used that.

But when I let my favorite editor (Eclipse) do some codecompletion I get:
<script language="JavaScript" type="text/javascript"
src="jsfile.js"></script>

Forget about the src for a moment.
I see 2 definition in the same tag.

Is that ok?
And on a sidenote: Am I safe when I use the modern type="text/javascript"
only? The answer probably depends on the browser.


Well, <script> is an element in HTML 4, you can find the syntax for HTML
4 on http://www.w3.org/TR/html4/interact/....html#h-18.2.1 where you
should find that the type attribute is mandatory while the language
attribute is deprecated. Thus if you want to author your HTML pages
according to the HTML 4 standard then you at least need
<script type="content type for your script language">
However there is no MIME type registered for JavaScript as far as I know so
<script type="text/javascript">
is what is common use but nothing standardized. Indeed some
implementations for script in SVG or XML pages use or at least allow
type="text/ecmascript".
As for HTML pages and browsers I think you are safe with
<script type="text/javascript">
modern browsers like IE5+, Netscape 6/7, Opera 7 support that and older
ones like Netscape 4 might not but default to assuming script is
JavaScript anyway.

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
On Thu, 19 Feb 2004 10:12:59 +0100, Erwin Moller
<si******************************************@spam yourself.com> wrote:
I am a bit cconfused with the different tags I encounter to start a
script.
I used to use: language="Javascript"
Bad.
Nowadays I use: type="text/javascript"
Very good.
I did see some javascript1.2 (i think) too, but never used that.
Oh so wrong! Specifying a version seems to cause odd parsing rules to be
invoked (for example, = meaning assignment *and* equal to[1]) and limiting
the available methods and properties that are available. Most people don't
understand the consequences of either.
But when I let my favorite editor (Eclipse) do some codecompletion I get:
<script language="JavaScript" type="text/javascript"
src="jsfile.js"></script>
My editor used to do that, but I fixed it. I don't know if you can in
Eclipse - look in the preferences.
Forget about the src for a moment.
I see 2 definition in the same tag.

Is that ok?
The language attribute is deprecated. Last week, I went on a trek through
the older HTML specifications to see exactly when this deprecation
occurred. This is what I found:

In version 2.0, there was no SCRIPT element.
In version 3.2, there were no formal attributes to the SCRIPT element.
In version 4.0, all of the current attributes were present, and language
was already deprecated.

What I conclude from that is that the language attribute was proprietary
(at a guess, probably Netscape) and was never a recommended part of the
HTML language. When the need to specify the scripting language was
identified, it was determined that the language attribute was inadequate
(values were inconsistent) so it was added to the specification, but at a
deprecated status. The type attribute, using MIME type values, was
recommended in its place. As such, it has never really been OK to use it,
apart from in the early days of version 4.0 and earlier, though strictly
for backward-compatibility purposes only.

[If I am totally off the mark, or if there is further information on this
subject, I would be interested in hearing it.]
And on a sidenote: Am I safe when I use the modern type="text/javascript"
only? The answer probably depends on the browser.
The type attribute is not modern. It first appeared in v4.0, which was
released just over six years ago. You will not encounter any problems
using it[2].
Where can I find some coherent information?


Just follow the specifications. In everything, that is the best you can
do. If there is an identified problem (such as IE's general lack of
standards support), then you should embark on a workaround for that
situation. I don't think it is, or should be, the author's job to cope for
broken or obsolete browsers (unless it is really in the interest of the
project).

That would be my assessment. Not normative, nor necessarily recommended,
by any stretch of the imagination.

Mike
[1] Mentioned by Randy Webb in an off-topic (at the time) discussion with
Richard Cornford and Lasse Nielsen.
[2] Even if a browser doesn't understand type, it is fairly guaranteed
that the browser will default to JavaScript anyway.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #3
Thanks a lot Mike!

(offers Mike a virtual beer)

You clarified that tricky stuff quite nicely and at a level somebody who
didn't dive into it for a week (=me) can understand. :-)

Darn, by the way, I called something 6 years old 'modern'.
I guess I am getting old. :P

Thanks for your time!

Regards,
Erwin Moller

Jul 20 '05 #4
Thanks for explaining that Martin!

Regards,
Erwin Moller
Jul 20 '05 #5
On Thu, 19 Feb 2004 15:30:56 +0100, Erwin Moller
<si******************************************@spam yourself.com> wrote:
Thanks a lot Mike!

(offers Mike a virtual beer)
Teetotal I'm afraid, but it's the thought that counts. :)
You clarified that tricky stuff quite nicely and at a level somebody who
didn't dive into it for a week (=me) can understand. :-)
I would like to remind you (for my sake as much as yours) that that was
mainly conjecture. I couldn't really find anything concrete. The
discussions about the language attribute either occurred behind closed
doors, or on the public mailing list[1] and the last time I tried to
search that, the engine rolled over and died, so I won't be trying again
in a hurry.

I'm hoping that someone else will either confirm my analysis (either
explicitly or through silence), or correct it. In any case, the debate
should be over historical accuracy, or lack thereof. The main theme should
still be the same: use type and avoid language.
Thanks for your time!


You're very welcome.

Mike
[1] By that, I mean there was nothing in the specification notes.

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 20 '05 #6
JRS: In article <op**************@news-text.blueyonder.co.uk>, seen in
news:comp.lang.javascript, Michael Winter <M.******@blueyonder.co.invali
d> posted at Thu, 19 Feb 2004 13:04:08 :-
[2] Even if a browser doesn't understand type, it is fairly guaranteed
that the browser will default to JavaScript anyway.


Unless the previous script on the page was not javascript (e.g.
VBscript).

I've not yet found anything in VB that looks useful for a mainly-JS
page, but a bit of JS could be used in a VB page for getTimeZoneOffset()

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://jibbering.com/faq/> Jim Ley's FAQ for news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Jul 20 '05 #7
Erwin Moller wrote:
But when I let my favorite editor (Eclipse) do some codecompletion I get:
<script language="JavaScript" type="text/javascript"
src="jsfile.js"></script>

Forget about the src for a moment.
I see 2 definition in the same tag.

Is that ok?


I presume you are writing about the "JavaScript *" templates of
the PHPeclipse plugin for eclipse, which is the only editor plugin
that I know of to do code completion and thus I happen to use, too.
If that is the case, you can change these templates with Window,
Preferences, PHP, Templates, <script, Edit, ..., OK, OK.
HTH & HAND

PointedEars
Jul 20 '05 #8

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

Similar topics

3
2263
by: Keith Little | last post by:
Hi Gurus, I've been searching high and low for an script to use on my website which suits my needs but I haven't found anything. Since I've never used PHP I'm hoping the open-source community...
3
2593
by: Vikram M Gautam | last post by:
hello, does any know of any php script which can change the language of the webpage on the fly, i have seen many websites which have several language options to choose from thanks
6
2073
by: lucy | last post by:
Hello comp.lang.js.I need a script to rotate a background image on each newpage load, given the id of the element and a list (array?)of 2 or more image paths ("img1.jpg", "img2.jpg", ...).Actually,...
6
1595
by: Brian | last post by:
Help.. We cannot get this script to work..can someone take a look at it and make suggestions? <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Convert...
2
1363
by: old_school_skater | last post by:
I'm new to html and Javascript and have been given an assignment from a friend to get me up to speed. I've followed instructions from Thomas A. Powells book HTML THE COMPLETE REFERENCE 3rd Edition...
9
1933
by: DavidB | last post by:
Hi all I have a script that works perfectly in IE but not in FF. I am sure that the problem is easy to resolve, but I seem to be too dumb to figure it out. <html> <head> <script...
4
1189
by: jackchang1 | last post by:
I just went across Douglas Crockford's website, and in this page, he mentions that the type/language attribute is not needed, since it is the server that determines the MIME type. But according to...
1
1507
by: mouton | last post by:
Hello, I am a beginner. My website has 2 pages: one in English and one in French. I would like non English people to be directed to the English page. There I would like to display a...
2
1155
by: kage | last post by:
I am trying to use this with mushclient 3.84 it supports these type of scripts. If anyone could help me figure out which type of script it is or convert it to any of those that my client uses....
8
5044
by: howa | last post by:
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...
0
7115
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6978
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
6858
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...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5451
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 project—planning, coding, testing,...
0
4578
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...
0
3086
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...
0
1392
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 ...
1
633
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.