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 :)