473,804 Members | 2,747 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Why no script type with onclick?

Out of curiosity, when I use onclick="...som e 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 2070
Brian Cryer wrote:
Out of curiosity, when I use onclick="...som e 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="VBScr ipt"
onclick="MsgBox window.event.ty pe">


--

Martin Honnen
http://JavaScript.FAQTs.com/
Mar 12 '08 #2
"Martin Honnen" <ma*******@yaho o.dewrote in message
news:47******** **************@ newsspool3.arco r-online.net...
Brian Cryer wrote:
>Out of curiosity, when I use onclick="...som e 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.1mandate s
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="VBScr ipt"
onclick="MsgBox window.event.ty pe">
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="VBScr ipt" onclick="MsgBox
window.event.ty pe">
However, that is not Valid HTML.
PointedEars
--
var bugRiddenCrashP ronePieceOfJunk = (
navigator.userA gent.indexOf('M SIE 5') != -1
&& navigator.userA gent.indexOf('M ac') != -1
) // Plone, register_functi on.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="VBScr ipt" onclick="MsgBox
window.event.t ype">

However, that is not Valid HTML.
<input type="button" value="test"
onclick="vbscri pt: MsgBox window.event.ty pe">

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
1373
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 forwarding to a link (just to make an example) it will work perfectly. What is wrong with the syntax? I am using internet explorer 5.50. This is the piece of script I am using: <br>
12
5273
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 ? for example html 4.0.1 versus xhtml 1.1 ???
4
2248
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 used. Thanks and regards, Vikas
2
3052
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 class="content"><script src="getimages.php"></script> ✉ The attribute given above is required for an element that you've used, but you have omitted it. For instance, in most HTML and XHTML document types the "type" attribute is required on the...
3
7846
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" src="funcs3.js"></script> ? And I need to use similarly multiple CSS:
9
4416
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 ( not in the latest Firefox ): "invalid character" The problem traces back to this line of code:
2
2702
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. I looked at the memory and it seems to be full. I removed all the javascript code - and the app seems to be have no leaks. As soon as I include my javascript code - the memory consumption gradually increases. Whether I actually invoke the...
7
2052
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 Dinosaur Quiz 6 </title> 7 <meta http-equiv="Content-Script-Type" content="type"> 8 next problemprevious problemE612 This tag or content is not allowed here: <script type="text/javascript"> 65 </script>
0
9711
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9591
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10594
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10343
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10087
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6861
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5667
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4306
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3831
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.