473,406 Members | 2,894 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,406 software developers and data experts.

OnClick

hi,
I wanted to know if OnClick can be used outside forms also?
like can plain text have the OnClick event handler associated with it?
thanks
Sumaira

Jul 20 '05 #1
5 6773
Sumaira Maqsood Ali <sa**@purdue.edu> writes:
I wanted to know if OnClick can be used outside forms also?
like can plain text have the OnClick event handler associated with it?


That depends on the browser.
I tested this code:
<p onclick="alert('foo');">text</p>
in my browsers, and it works in IE6, Mozilla Firebird 0.6 and Opera 6+.
It didn't work in Netscape 4.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #2
Sumaira Maqsood Ali wrote:
hi,
I wanted to know if OnClick can be used outside forms also?
like can plain text have the OnClick event handler associated with it?


http://www.w3.org/TR/html4/interact/....html#h-18.2.3

onclick = script [CT]
The onclick event occurs when the pointing device button is clicked over
an element. This attribute may be used with most elements.

--
David Dorward http://david.us-lot.org/
Which is stupider: Pop-up ads claiming they'll stop spam, or spam claiming
it'll stop pop-up ads? -- Dork Tower
Jul 20 '05 #3
Lee
Lasse said:

Sumaira Maqsood Ali <sa**@purdue.edu> writes:
I wanted to know if OnClick can be used outside forms also?
like can plain text have the OnClick event handler associated with it?


That depends on the browser.
I tested this code:
<p onclick="alert('foo');">text</p>
in my browsers, and it works in IE6, Mozilla Firebird 0.6 and Opera 6+.
It didn't work in Netscape 4.


In Netscape 4, you can enclose the text in a Link, with text-decoration:none.

<head>
<style type="text/css">
A {text-decoration:none}
</style>
</head>
<body>
Click <a href="about: Me" onclick="alert('hello');return false">Me</a>.
</body>

Note that this example behaves badly if Javascript isn't enabled.

Jul 20 '05 #4
Sumaira Maqsood Ali <sa**@purdue.edu> writes:
It works if I do onClick='alert(....)' but it doesnt work if i do
onClick='somefunction(....)' why is that so?


That must be because "somefunction" doesn't exist or doesn't work,
or there is a typo in the call to it.
/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #5
In article <3F**************@purdue.edu>, sa**@purdue.edu enlightened us
with...
It works if I do onClick='alert(....)' but it doesnt work if i do
onClick='somefunction(....)' why is that so?
thanks
sumaira


You probably have an error in the function or you spelled it differently
- capitalization matters.

-------------------------------------------------
~kaeli~
Black holes were created when God divided by 0.
Not one shred of evidence supports the notion
that life is serious.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
-------------------------------------------------
Jul 20 '05 #6

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

Similar topics

8
by: Shock | last post by:
Hello everyone, I am having a problem with the program below. I have isolated the problem to the onclick event that is located throughout arrQuestions. The onclick event refers to a function...
17
by: Mike Gratee | last post by:
Is it possible to use JavaScript to cause the browser to click a link on a page and have the browser act exactly like the user had clicked on the link directly? In other words, I need to...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
3
by: Jamie Jackson | last post by:
I'm rewriting all links' onclick events, but I'm having a problem. The onclick event that I'm inserting works correctly in Opera, but not in FF or IE. I'm retroactively adding the statement...
2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
2
by: Sedef | last post by:
Hi, i'm trying to create a custom Button user control which will be derived from System.Web.UI.WebControls.Button. the normal server side Button class creates some client side javascript code for...
4
by: Mark Rae | last post by:
Hi, VS.NET 2003 on WinXPPro, both with all the latest patches and updates, etc... I've got a very simple WebForm which is used either to add a new record to a SQL Server database or edit a...
6
by: Nx | last post by:
i've got it all working nicely in firefox, but whenever i test it in IE none of the onclick events are triggered. i'm using an xsl to transform an rss feed into a photogallery. when i try to...
7
by: extremerep | last post by:
My task is to change the value of a button and then make it functional with the onClick handler. Changing the value to "Play Again" works, but making the onClick work accordingly does not. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.