Web Hosting Directory | Web Hosting Resources | Webmaster Resources | Domain Tools | Search Engine Marketing | Forums
  Signup
Today: 1,134   Yesterday: 1,240   Max: 1,872   Total: 364,534   Current Users : 12 (Member 0) 
DOMAIN TOOLS

WEBMASTER TOOLS

RELATED ARTICLES

SUBMIT AN ARTICLE

Write for us and get publicity, link to your website, and best of all get paid. Please visit our writers page for details.


LINK TO US

Link to us and earn points for each visitor you bring to us. Please visit our link partner page for details.

 

Attribute for <A ...>
onClick = "script command(s)"

Looking for Information on Popup Windows?

You might want to check out our Popup Windows.
onClick sets a script to run when the user clicks on the link. For example, this link creates an alert box which says Heading Home! when the link is clicked:

this code produces this
<A HREF="mypage.oc.php" onClick="alert('Heading Home!')">My Page</A>
My Page

One of the more useful uses of onClick is creating a popup window which the links targets. This example uses our popup window script (see Popup Window Tutorial).

this code produces this
<A 
    HREF="mypage.popup.php" 
    onClick="return openWindow(this,'mypage')"
    >My Page</A>
My Page

If onClick returns a value of false then the click is cancelled and the browser doesn't go anywhere. For example, you could check if a user really wanted to go to a URL like this:

this code produces this
<A 
    HREF="deleted.oc.php" 
    onCLick="return confirm('Are you SURE you want to delete this record?')"
    >Delete It!</A>
Delete It!



Copyright 1997-2002 Idocs, Inc. Written by Miko Sullivan.

 
 
What is your major source of website traffic?
 
 
 
 
 
 

ADVERTISEMENT

 
Cheap Web HostingBudget Web HostingEcommerce Web Hosting
Link to UsLink ExchangeAdvertisePrivacy PolicyTerms Of ServiceAbout UsContact UsSitemap
Copyright © 2006 - 2008 Broadband Media, Inc. All rights reserved.