Web Development HTML Guide - Learn HTML
Developer Tutorials
ASP
CGI & Perl
CSS
Flash
HTML
Java
JavaScript
Linux
MySQL
PHP
Photoshop
Python
Wireless
XML



Developer Manuals
Learn HTML
Learn PHP
Learn MySQL
Learn CSS
Learn Pear


Developer Scripts
ASP Scripts
ASP.NET Scripts
CGI & Perl Scripts
Flash Scripts
Java Scripts
JavaScript Scripts
PHP Scripts
Python Scripts
Remotely Hosted Scripts
Tools & Utilities Scripts
XML Scripts

Developer Resources
Developer Tools
Developer News
Developer Forums
Developer Content
Developer Book Reviews
Survey Software

Web Hosting Directory
Budget Web Hosting
ColdFusion Hosting
Dedicated Servers
Domain Hosting
E-Commerce Hosting
Email Hosting
Free Web Hosting
Linux Web Hosting
Managed Hosting
Reseller Hosting
Small Business Hosting
Windows Web Hosting

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.html" 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.html" 
    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.html" 
    onCLick="return confirm('Are you SURE you want to delete this record?')"
    >Delete It!</A>
Delete It!


Copyright Idocs, Inc. Written by Miko Sullivan











About the NetVisits, Inc Network | Advertise
Developer Tutorials hosted by HostGator.
Copyright ©2007 NetVisits, Inc Network. All Rights Reserved. Privacy Policy.
Visit other NetVisits, Inc. sites: