Skip to main content
gamedev.net
🔒 Locked

[web] disabling a hyperlink

Started by ballack Jun 8, 2006 at 12:47 AM 5 replies 6.9k views
Original Post
ballack
ballack
hi everyone, i want to know how can i disable a hyperlink in html using &#106avascript. for example i ve a checkbox when a user unchecks the check box the link should be disabled. can anyone help me with this? -Glen
swordfish
swordfish
I don't know enough about the topic, but I'm pretty sure you can use JS with CSS to accomplish the task.
http://blog.protonovus.com/
ballack
ballack
Thank you.
but i woulld be glad if anyone can tell which specific CSS that i must use .
Avatar God
Avatar God
You could swap out two entire divs/spans based on that event. The 'normal' one would include a hyperlink, and the post-click one would be standard text.
gsgraham.comSo, no, zebras are not causing hurricanes.
gavco98
gavco98
I dont know if you can disable a hyperlink, however you can hide a DIV. If you created two divs at the same location, one containing a hyperlink and one containing a standard piece of text, you could then swap between the two.

&#106avascript show/hide layer sample code</a></a>
Gavin Coates
[size="1"]IT Engineer / Web Developer / Aviation Consultant
[size="1"][ Taxiway Alpha ] [ Personal Home Page ]
benryves
benryves
You can do this by using the 'onclick' handler on the link - return false to disable the link, true to enable it.
As an example, the following link only works the 3rd time you click on it:


Link<script language="JavaScript">var count = 1;function condition() {    return (count++ == 3);}</script>
[Website] [+++ Divide By Cucumber Error. Please Reinstall Universe And Reboot +++]
kanzler
kanzler
Something like this?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><title>TEST</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script type="text/javascript">function updateLink(srcCheckbox, linkId){	var theLink = document.getElementById(linkId);	if (theLink)	{		if (srcCheckbox.checked)			theLink.style.visibility = 'visible';		else			theLink.style.visibility = 'hidden';	}};</script></head><body><input type="checkbox" name="myCheckbox" onclick="updateLink(this, 'myLink');" checked /> Click me!

Go to GameDev.net

</body></html>

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.