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

Disable/lock a hyperlink using Javascript

is it possible? using dhtml?
its for a logout link.. once youve clicked it,
you can no longer click it (while it forwards to the logout page).
0
ibo
Asked:
ibo
1 Solution
 
iboAuthor Commented:
btw i created this one and serves it purpose but users wants the link itself be locked or unclickable.

<script language="javascript">
    var firstTimeLogOut = true;
    function logOut() {
        if (firstTimeLogOut) { // trap any multiple clicks during logout
            firstTimeLogOut = false;
            window.location.href = "logout.xxx";
        }
    }
</script>
0
 
dakydCommented:
Not sure if it's exactly what you're looking for, but how about something like the following?

<a href="logout.xxx" onload="if (top.document.location.href == 'logout.xxx') this.href='#';" />Logout</a>

The idea is that when the address bar shows logout.xxx, the link changes its href value to #, which won't go anywhere.  If you copy that link exactly to any page but logout.xxx, it'll go to logout.xxx, but on the logout page, it won't do anything.  Hope that helps.
0
 
sajuksCommented:
<a href="http://www.experts-exchange.com"  onclick="this.disabled=true;">E-E</a><br>
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
iboAuthor Commented:
hmm how about just hiding the link itself and a text label appears in place of the link? how do i do that?
0
 
iboAuthor Commented:
can i make a link became a plain text label after clicking it?
0
 
Webby_Commented:
<span id="logout"><a href="logout.xxx" onClick="document.getElementById('logout').innerHTML='logout';">logout</a></span>
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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