Connecting Tech Pros Worldwide Help | Site Map

Why no script type with onclick?

 
LinkBack Thread Tools Search this Thread
  #1  
Old March 12th, 2008, 02:25 PM
Brian Cryer
Guest
 
Posts: n/a
Default Why no script type with onclick?

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, 02:45 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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, 10:15 AM
Brian Cryer
Guest
 
Posts: n/a
Default 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, 10:55 PM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default 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, 06:55 AM
Thomas 'PointedEars' Lahn
Guest
 
Posts: n/a
Default 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
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.