Using <script src> tag, is type required?

R

Randell D.

Folks,

Do I need to use the 'type' in the javascrpit external load request below?
Is it mandatory or optional? I've not found a clear reference on this...

<script language='JavaScript' type='text/javascript' src=/myScrpit.js>

thanks... replies via ng only please
randelld
 
M

Martin Honnen

Randell said:
Do I need to use the 'type' in the javascrpit external load request below?
Is it mandatory or optional? I've not found a clear reference on this...

<script language='JavaScript' type='text/javascript' src=/myScrpit.js>

If you want to write HTML according to the HTML 4.01 standard then you
need to have a type attribute for your <script> elements (any <script>
element not only those having a src attribute).
 
L

Lasse Reichstein Nielsen

Randell D. said:
Do I need to use the 'type' in the javascrpit external load request below?

"need" is vague :) Will it work without it? Probably in some browsers,
maybe even all. But ...
Is it mandatory or optional? I've not found a clear reference on this...

It is required by the HTML 4 specification. Check
<URL:http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.1>
---
type %ContentType; #REQUIRED -- content type of script language --
---
<script language='JavaScript' type='text/javascript' src=/myScrpit.js>

The "language" attribute is not needed, and it is deprecated in favor
of "type".
thanks... replies via ng only please

Ofcourse :)

/L
 
D

David Dorward

Martin said:
If you want to write HTML according to the HTML 4.01 standard then you
need to have a type attribute for your <script> elements (any <script>
element not only those having a src attribute).

You also need to quote the value of the source attribute (it contains a "/"
so the quotes are not optional), and add a closing tag.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,765
Messages
2,569,568
Members
45,042
Latest member
icassiem

Latest Threads

Top