Forum Moderators: open

Message Too Old, No Replies

type="text/javascript"

Back to basics

         

Alternative Future

10:36 am on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi to the forum,

What are the reasons behind using the type="text/javascript" to the script tag again? Ok it tells the parser that the following segment is using basic text and javascript etc (I think) but what other reasons does it exist for i.e does it help the parser serve the javascript faster etc?

TIA,

-George

kaled

2:43 pm on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



So far as I can tell, it does nothing other than allow your code to validate. Take it out and your code will work fine.

Kaled.

Alternative Future

2:50 pm on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks kaled,

This was brought to my attention when the company upgraded to the recent IntelliJ 5.0 which validates all script tags. It then says that 'Element script doesn’t have required attribute type'

I was just curious if there were any benefits to be had from its usage.

Thanks again,

-George

moltar

3:01 pm on Sep 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There is more than one type of client side scripts. They may not be as popular, but they exists. I know of at least two other ones: Tcl and VBScript. In future we might get even more.

dcrombie

3:33 pm on Sep 21, 2005 (gmt 0)



If it's not specified then Explorer will assume it's the same type as the last script it processed (from the same page or even another site). So it could try to parse your JScript as VBScript or vice versa.

Alternative Future

10:43 am on Sep 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thx moltar & dcrombie,

What you say dcrombie is interesting do you have any online resources that cover this?

TIA,

-George

dcrombie

12:11 pm on Sep 22, 2005 (gmt 0)



I saw that a few years ago - probably w.r.t. version 4. The behaviour might have changed by now.

[blogs.msdn.com...]

... language will default to be JScript for the page unless otherwise specified. Once you have specified a language that will be the default language for the rest of the page unless you explicitly change it ...

;)