Connecting Tech Pros Worldwide Help | Site Map

Why no script type with onclick?

  #1  
Old March 12th, 2008, 03:25 PM
Brian Cryer
Guest
 
Posts: n/a
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


  #2  
Old March 12th, 2008, 03:45 PM
Martin Honnen
Guest
 
Posts: n/a

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/
  #3  
Old March 13th, 2008, 11:15 AM
Brian Cryer
Guest
 
Posts: n/a

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.


  #4  
Old March 13th, 2008, 11:55 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

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
  #5  
Old March 15th, 2008, 07:55 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Add Row (DOM) with onClick Function jj6849 answers 4 November 1st, 2006 09:36 AM
disable or prevent a button with onclick and javascript techfuzz answers 2 November 17th, 2005 07:51 PM
dynamically add a table row with onclick cool2005 answers 8 July 23rd, 2005 08:42 PM
problem with onclick Draken answers 5 July 20th, 2005 09:49 AM