472,358 Members | 1,727 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,358 software developers and data experts.

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 1784


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
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
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
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
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
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
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
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
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
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
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
1
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.