OnClick

  • Thread starter Sumaira Maqsood Ali
  • Start date
S

Sumaira Maqsood Ali

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
 
L

Lasse Reichstein Nielsen

Sumaira Maqsood Ali said:
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
 
L

Lee

Lasse said:
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.
 
L

Lasse Reichstein Nielsen

Sumaira Maqsood Ali said:
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
 
K

kaeli

[email protected] enlightened us said:
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
-------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,077
Messages
2,570,569
Members
47,205
Latest member
KelleM857

Latest Threads

Top