Solved

Disable/lock a hyperlink using Javascript

Posted on 2004-10-05
6
407 Views
Last Modified: 2008-02-01
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
Comment
Question by:ibo
6 Comments
 
LVL 3

Author Comment

by:ibo
Comment Utility
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
 
LVL 19

Expert Comment

by:dakyd
Comment Utility
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
 
LVL 33

Expert Comment

by:sajuks
Comment Utility
<a href="http://www.experts-exchange.com"  onclick="this.disabled=true;">E-E</a><br>
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 3

Author Comment

by:ibo
Comment Utility
hmm how about just hiding the link itself and a text label appears in place of the link? how do i do that?
0
 
LVL 3

Author Comment

by:ibo
Comment Utility
can i make a link became a plain text label after clicking it?
0
 
LVL 1

Accepted Solution

by:
Webby_ earned 30 total points
Comment Utility
<span id="logout"><a href="logout.xxx" onClick="document.getElementById('logout').innerHTML='logout';">logout</a></span>
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now