Connecting Tech Pros Worldwide Help | Site Map

Why no script type with onclick?

Brian Cryer
Guest
 
Posts: n/a
#1: Mar 12 '08
Out of curiosity, when I use onclick="...some JavaScript ..." why do I not
need to flag that its JavaScript, but when I define a script on a page I do
need to tag it (<script type="text/javascript">...)?

Is it part of the standard that event handlers (onclick etc) are always
JavaScript?

Just curious. TIA.
--
Brian Cryer
www.cryer.co.uk/brian


Martin Honnen
Guest
 
Posts: n/a
#2: Mar 12 '08

re: Why no script type with onclick?


Brian Cryer wrote:
Quote:
Out of curiosity, when I use onclick="...some JavaScript ..." why do I not
need to flag that its JavaScript, but when I define a script on a page I do
need to tag it (<script type="text/javascript">...)?
>
Is it part of the standard that event handlers (onclick etc) are always
JavaScript?
The HTML 4 standard
<URL:http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2.1>
mandates that you provide a HTTP header or a meta element
<meta http-equiv="Content-Script-Type" content="text/javascript">
but I don't know of browsers implementing that, they either support only
JavaScript and therefore default to JavaScript in event handlers or
(IE/Win) they have their own way of choosing the language: with IE the
first script element and its language or type attribute determine the
language for event handlers, additionally you can put the language in an
attribute to indicate the language on a per element basis
<input type="button" value="test" language="VBScript"
onclick="MsgBox window.event.type">




--

Martin Honnen
http://JavaScript.FAQTs.com/
Brian Cryer
Guest
 
Posts: n/a
#3: Mar 13 '08

re: Why no script type with onclick?


"Martin Honnen" <mahotrash@yahoo.dewrote in message
news:47d7eb26$0$6723$9b4e6d93@newsspool3.arcor-online.net...
Quote:
Brian Cryer wrote:
Quote:
>Out of curiosity, when I use onclick="...some JavaScript ..." why do I
>not need to flag that its JavaScript, but when I define a script on a
>page I do need to tag it (<script type="text/javascript">...)?
>>
>Is it part of the standard that event handlers (onclick etc) are always
>JavaScript?
>
The HTML 4 standard
<URL:http://www.w3.org/TR/html4/interact/scripts.html#h-18.2.2.1mandates
that you provide a HTTP header or a meta element
<meta http-equiv="Content-Script-Type" content="text/javascript">
but I don't know of browsers implementing that, they either support only
JavaScript and therefore default to JavaScript in event handlers or
(IE/Win) they have their own way of choosing the language: with IE the
first script element and its language or type attribute determine the
language for event handlers, additionally you can put the language in an
attribute to indicate the language on a per element basis
<input type="button" value="test" language="VBScript"
onclick="MsgBox window.event.type">
Thank you Martin.


Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#4: Mar 13 '08

re: Why no script type with onclick?


Martin Honnen wrote:
Quote:
[...] with IE the first script element and its language or type attribute
determine the language for event handlers, additionally you can put the
language in an attribute to indicate the language on a per element basis
<input type="button" value="test" language="VBScript" onclick="MsgBox
window.event.type">
However, that is not Valid HTML.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
#5: Mar 15 '08

re: Why no script type with onclick?


Thomas 'PointedEars' Lahn wrote:
Quote:
Martin Honnen wrote:
Quote:
>[...] with IE the first script element and its language or type attribute
>determine the language for event handlers, additionally you can put the
>language in an attribute to indicate the language on a per element basis
><input type="button" value="test" language="VBScript" onclick="MsgBox
>window.event.type">
>
However, that is not Valid HTML.
<input type="button" value="test"
onclick="vbscript: MsgBox window.event.type">

is. However, you don't want to use VBScript, not on the Web anyway as it's
MSHTML-only (AFAIK).


PointedEars
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann
Closed Thread