spacer
Yehuda Shiran November 18, 1999
Cancelling a Link
Tips: November 1999

Yehuda Shiran, Ph.D.
Doc JavaScript

Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

When the user clicks on a link, the browser normally loads the specified Web page. With JavaScript we can cancel this process:

<A HREF="http://www.docjs.com/" onClick="return false">Doc JavaScript</A>

When the user clicks this link (Doc JavaScript), nothing happens. The onClick event handler returns false, so the specified URL isn't loaded. The following link asks the user to confirm the click:

<SCRIPT LANGUAGE="JavaScript">
<!--

function areSure() {
  return confirm("Are you sure?");
}

// -->
</SCRIPT>
<A HREF="http://www.docjs.com/" onClick="return areSure()">Doc JavaScript</A>

When the user clicks this link (Doc JavaScript) a confirm dialog box pops up. If the user clicks OK, the page http://www.docjs.com/ is loaded. If the Cancel button is pressed, the page isn't loaded.


People who read this tip also read these tips:

Look for similar tips by subject:

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint