473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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
Mar 12 '08 #1
4 2053
Brian Cryer wrote:
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/
Mar 12 '08 #2
"Martin Honnen" <ma*******@yahoo.dewrote in message
news:47**********************@newsspool3.arcor-online.net...
Brian Cryer wrote:
>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.
Mar 13 '08 #3
Martin Honnen wrote:
[...] 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
Mar 13 '08 #4
Thomas 'PointedEars' Lahn wrote:
Martin Honnen wrote:
>[...] 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
Mar 15 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Gigi | last post by:
Hi all, I have to make start a shell script using the javascript command onClick. The path is correct but it the script doesn't want to start. On the other hand, if I use the same command for...
12
by: =?ISO-8859-1?Q?Une_B=E9vue?= | last post by:
two possibilities or the attribute type of script : text/javascript (the one i usually use) application/x-javascript what are the differencies between both ? depends on the html content ?...
4
vikas251074
by: vikas251074 | last post by:
Hello everybody, Should I use script language attribute or script type? Is there any difference? Until now I have used script language attribute in my all programme where javascript has to be...
2
pradeepjain
by: pradeepjain | last post by:
<script src="getimages.php"></script> i am using this to run a script but dring validation it gives error as " Line 285, Column 51: required attribute "type" not specified. <div...
3
by: joe | last post by:
Is it OK to have multiple: <script type="text/javascript" src="funcs1.js"></script> <script type="text/javascript" src="funcs2.js"></script> <script type="text/javascript"...
9
by: Steve | last post by:
Hi; I've being going through some legacy code on an old JSP site I have been patching. I noticed that when I save the JSP down to my PC as an HTML file I get this javascript error in IE 6 ( ...
2
by: Jay | last post by:
I have a web app running on the windows CE device. In one of the asp.net pages - it has javascript code. That seems to have a memory leak. When I run the web app - in about one hour, the app hangs....
7
by: Kathlyn Gonzale | last post by:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml-strict.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml"> 5 <head> 6 <title> 6 ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.