By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,636 Members | 1,181 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,636 IT Pros & Developers. It's quick & easy.

Using <script src> tag, is type required?

P: n/a

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
Share this Question
Share on Google+
4 Replies


P: n/a


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

P: n/a
"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

P: n/a
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

P: n/a

Thanks to all for clarifying usage...

Cheers
randelld
Jul 20 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.