faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

13 of 16 people (81%) answered Yes
Recently 7 of 10 people (70%) answered Yes

Entry

when i click on text in html document i can't take a event window.onclick how i can do it in NN4

Apr 4th, 2008 19:46
ha mo, Iván Rivera, Max Snowman,


Unfortunately, you can't. NS4.x doesn't give access to such events for
normal text.
However, there is a workaround: set up the text that is to receive the
clicks as anchor text (between <A>...</A> tags). Use the onClick event
handler available for the A tag to determine the behavior you want, and
assign a CSS class or style for eliminating the anchor default appearance.
CSS classes are the better approach if you want to have various text
blocks set up in this fashion: you should create an inline style sheet,
inside the <HEAD> section of your page.
<STYLE TYPE="text/css">
.clickableText {text-decoration:none; color:black}
</STYLE>
Adjust the color to your preference. You can use standard names or hex
triplets like this one: #ffffff (that is white).
Add the CSS rule to your style sheet if you already have one; and assign
the newly created class to your anchor text:
  <A HREF="#" CLASS="clickableText" onClick="yourJSFunction()">This is
my clickable text!</A>
This technique works in all browsers supporting CSS.
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com