469,282 Members | 1,704 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

Using <script src> tag, is type required?


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
Jul 20 '05 #1
4 1878


Randell D. wrote:
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).

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #2
"Randell D." <re**********************@and.share.com> writes:
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
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #3
Martin Honnen wrote:
<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).


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.

--
David Dorward <http://dorward.me.uk/>
Jul 20 '05 #4

Thanks to all for clarifying usage...

Cheers
randelld
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

30 posts views Thread by Toni Mcintyre | last post: by
2 posts views Thread by Jeffrey T. | last post: by
21 posts views Thread by hemant.singh | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.