• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 419
  • Last Modified:

Disable hyperlink to prevent double clicking

I want to disable a hyperlink after the user has clicked once. e;g

<a href="dothis.cfm?arg1=a>Cleck me once</a>

Open in new window

I can assume all users re using IE 6 or later.
3 Solutions
try both:
<a href="dothis.cfm?arg1=a" onclick="isClicked()" id="submitButton">Cleck me once</a>
<a href="dothis.cfm?arg1=a" id='submitButton'  onclick="document.getElementById('submitButton').style.display = 'none';">Cleck me once</a>
Gurvinder Pal SinghCommented:
simplest one
<a href="javascript:goToURL( this )">Cleck me once</a>

function goToURL( thisObj )
    location.href = "dothis.cfm?arg1=a";

Solution with error message if already clicked.

<a href="http://google.com" onclick="if (this._clicked) { alert('Already clicked.'); return false; } this._clicked = true;" target="_blank">Click me only once</a>

Open in new window

In this example first click opens google, second and all next will do nothing and display alert.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Easily Design & Build Your Next Website

Squarespace’s all-in-one platform gives you everything you need to express yourself creatively online, whether it is with a domain, website, or online store. Get started with your free trial today, and when ready, take 10% off your first purchase with offer code 'EXPERTS'.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now