Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Mail Systems
Eclipse Documentation

How To Guides
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Problem Solutions
Privacy Policy




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

  Copyright 1997-2002 Idocs inc. Published under the terms of the Open Content License Design by Interspire