473,324 Members | 2,501 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

difference between "text/javascript" and "JavaScript"

Hi

I am new to Javascript and am not sure what is the difference between the
following two statements:

<script type="text/javascript">
.....
</script>
and
<SCRIPT LANGUAGE = "JavaScript">
<!--
.....
</SCRIPT>

Can someone elaborate on this? Thanks
Apr 18 '07 #1
2 3559
Navodit said the following on 4/18/2007 12:11 PM:
Hi

I am new to Javascript and am not sure what is the difference between the
following two statements:
The first is required by the validator, the second is deprecated by the
validator (although both are deprecated).
<script type="text/javascript">
....
</script>
and
<SCRIPT LANGUAGE = "JavaScript">
<!--
....
</SCRIPT>

Can someone elaborate on this? Thanks
Aside from the validator barfing on that language attribute, there are
some versions of the language attribute (javascript1.2 is the most
prevelant) can cause some unexpected behavior in some browsers.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Apr 18 '07 #2
dd
On Apr 18, 6:11 pm, "Navodit" <kaush...@uiuc.eduwrote:
I am new to Javascript and am not sure what is the difference between the
following two statements:
<script type="text/javascript">
and
<SCRIPT LANGUAGE = "JavaScript">
Can someone elaborate on this? Thanks
The language="javascript" is the oldest syntax and is supported
by all browsers, even the newest. The <script part tells the HTML
parser what it's about to receive, and the language parts tells it
that the script is in javascript format.

The type="text/javascript" came along later and was meant to be
the preferred new method of declaring javascript. This relates to
mimetype and instructs the browser that it's plain text and the
language is javascript. I imagine the idea was that you might be
able to have compressed text also e.g., "compressed/javascript"
but that never came into existence. This is just speculation here.

When text/javascript came along they did something that has
been mostly used by the Java community, which is to "deprecate"
the old style language tag.

That means simply that they don't recommend using that in any
new code, and when time permits (or next time you're working on
it) update any old code. There's never been any timetable on
when language="javascript" would no longer be supported, and
as it's used so widely across the internet, nobody wants to break
lots of webpages that sit out there unmodified and will do so for
years to come. So NO NEW browsers have ceased supporting the
language tag and I doubt without any other major sweeping change
in the web occurring, it will become unsupported.

All my code releases continue to use language="javascript" and
will continue to until a new browser comes along that doesn't like it.
I don't see the benefit of changing my code and suddenly alienating
any older browsers that maybe don't know about it. It ain't broke so
I'm not going to try fixing it :)

Apr 19 '07 #3

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

Similar topics

9
by: Marcus Sheen [UK] | last post by:
Have done searches for similar questions, but cannot find anything. Nor can I find any resources via Google (Javascript Source etc). Thinking about implementing a topical "On This Day" feature on...
25
by: delerious | last post by:
I see some code examples like this: <DIV onmouseover="this.style.background='blue'"> and other code examples like this: <DIV onmouseover="javascript:this.style.background='blue'"> Which...
9
by: David D. | last post by:
Does the file extension matter when including a JavaScript file in an HTML page? Normally, one would include a JavaScript file in an HTML page using <script src="foo.JS" type="text/javascript">...
6
by: Jon Davis | last post by:
I recently learned how to do an <OBJECT> alternative to <IFRAME> in current browsers using: <object id="extendedhtml" type="text/html" data="otherpage.html" width="250" height="400"></object> ...
2
by: mstearne | last post by:
Has anyone seen any Javascript that mimics the effect that allows you to browse through the New Releases, Just Added sections of the iTunes Music Store? Where you click the arrow icon and the next...
3
by: ljwheeler | last post by:
I've been fighting this problem all day but can't seem to get it to work no matter what I try. I would think it would be very simple, but... rdmMovie.js ========= <!-- Script...
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
9
by: Steve | last post by:
Hi; I've being going through some legacy code on an old JSP site I have been patching. I noticed that when I save the JSP down to my PC as an HTML file I get this javascript error in IE 6 ( ...
19
by: maya | last post by:
hi, so what is "modern" javascript?? the same as "DOM-scripting"? i.e., editing content (or changing appearance of content) dynamically by massaging javascript objects, html elements, etc? ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.