please dont rip this site

JavaScript: The Definitive Guide

Previous Chapter 21
JavaScript Reference
 
 

Link.onclick() Handler

Name

Link.onclick() Handler---invoked when a Link is clicked

Availability

Navigator 2.0, Internet Explorer 3.0; enhanced in Navigator 3.0

Synopsis

<A onClick="handler-statements">    a definition of the handler
<AREA onClick="handler-statements"> another definition; Navigator 3.0 only
link.onclick  a reference to the handler
link.onclick();   an explicit invocation of the handler

Description

onclick() is an event-handler function invoked when the user clicks on a hypertext link. This event handler is defined by the onClick attribute of the HTML <A> or <AREA> tag that defines the hypertext link. The value of this attribute may be any number of JavaScript statements, separated by semicolons. These statements will be executed when the user clicks on the link.

The onclick() event handler is invoked before the browser follows the clicked hypertext link. This allows you to set the href, target, and other properties of the link dynamically (using the this keyword to refer to the clicked link). You may also use Window.alert(), Window.confirm(), and Window.prompt() from this event handler.

In Navigator 3.0, you may prevent the browser from following the link by returning false. If you return true, or any other value, or nothing, then the browser will follow the link as soon as onclick() returns. You might stop the browser from following a link if you used the Window.confirm() method to ask the user if they really want to follow the link and they choose the Cancel button, for example. In general, if you want a link that performs some action but does not cause a new URL to be displayed, it is better to use a the onclick() event handler of a Button object instead of the onclick() handler of a Link object.

Note that while this event handler returns false to tell the browser not to perform its default action (following a link), the onmouseover() event handler must return true to tell the browser not to take its default action (displaying the URL of the link). This incompatibility exists for historical reasons. The standard for Form and form element event handlers is to return false to prevent the browser from performing a default action.

Bugs

In Navigator 3.0, the onclick() event handler of the <AREA> does not work on Windows platforms. Because this is a very common platform, you should avoid using this event handler in client-side image maps. Instead, you can often specify a javascript: URL as the value of the HREF attribute of the <AREA> tag.

See Also

"Link"


Previous Home  
Link.href Book Index  

HTML: The Definitive Guide CGI Programming JavaScript: The Definitive Guide Programming Perl WebMaster in a Nutshell

file: /Techref/language/JAVA/script/definitive/refp_199.htm, 6KB, , updated: 2019/10/14 15:00, local time: 2024/12/4 17:32,
TOP NEW HELP FIND: 
3.147.205.19:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://sxlist.com/Techref/language/JAVA/script/definitive/refp_199.htm"> [Chapter 21] Reference: Link.onclick()</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to sxlist.com!


Site supported by
sales, advertizing,
& kind contributors
just like you!

Please don't rip/copy
(here's why

Copies of the site on CD
are available at minimal cost.
 
Quick, Easy and CHEAP! RCL-1 RS232 Level Converter in a DB9 backshell
Ashley Roll has put together a really nice little unit here. Leave off the MAX232 and keep these handy for the few times you need true RS232!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .