Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Disable anchor tag in Firefox?

Status
Not open for further replies.

rjohn2001

Programmer
Nov 21, 2005
24
0
0
GB
Hi all,
Can some one please have a look at it and guide me what's wrong with this anchor tag.It works fine in IE but not in firefox..

Code:
<a class="Item" href="" Onclick="javascript:return false;" style="width:100" disabled>Contents</a>

Thanks
 
If all you want is a piece of text saying "Contents" then dispense with the anchor tag.

If that's not what you want, maybe you could elaborte on why you need an anchor that is disabled.

Hope this helps,
Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan
I want to have a conditional Disable/Enable statement.

Depends on my value from asp i want to turn this anchor tag on or off.

Thanks
 
Dan, i am sure this will work but i'm looking for any other better solution we have as i need to use this solution in many places..

any other ideas as we have a nice attribute in IE(disabled) so some thing for firefox please..
 
If you must do this with JavaScript, despite the fact that you clearly have server-side scripting available to you, and the decision to use the link or not is made server-side anyway, then this will work:

Code:
<a href="someLink.html" onclick="return(false);">Text</a>

I still think you are better off not delivering the link, as people with no JavaScript will still see a functioning link. That is the "con", so now you get to make the decision based upon that information.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks Dan, so it seems we don't have any easy alternative for the disabled(IE) attribute.
The solution you have suggested should work without any doubt and indeed i am doing that, but we need to do the cosmetics to get the disabled look so what i am thinking is to change the color(#ACA899) of the link and disable onclick

so this should work..any suggestions always welcome..thanks for the help Dan
 
indeed i am doing that, but we need to do the cosmetics to get the disabled look so what i am thinking is to change the color(#ACA899) of the link and disable onclick

Why didn't you tell us that to start with, rather than just asking for a link to be disabled? It would have saved so much hassle!

To change the colour, you can use the style attribute:

Code:
<a href="somePage.html" style="color:#ACA899;">text</a>

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top