Disabling links

T

Terry

I thought that <a href="nowhere.htm" onclick="javascript: return
false">
would disable that link. It does in Firefox but is not doing so in
IE.

Am I doing something wrong? Is there a way to do it that is cross-
browser safe?

Thanks,
Terry
 
E

Evertjan.

Terry wrote on 21 sep 2007 in comp.lang.javascript:
I thought that <a href="nowhere.htm" onclick="javascript: return
false">
would disable that link. It does in Firefox but is not doing so in
IE.

Am I doing something wrong?

Yes.

1 the javascript: is not neccessary,
(unless you have clientside [IE only] vbscript on the same page)

2 it works in IE.

Is there a way to do it that is cross-browser safe?

No,
when Javascript is absent or deactivated in the browser
or has simply errored out,
the link is followed.
 
I

Ivan Marsh

I thought that <a href="nowhere.htm" onclick="javascript: return
false">
would disable that link. It does in Firefox but is not doing so in
IE.

Am I doing something wrong? Is there a way to do it that is cross-
browser safe?

This my be a stupid question by why would you bother to provide a link
in the first place if you intend for it to be disabled?
 
S

Steve Swift

This my be a stupid question by why would you bother to provide a link
in the first place if you intend for it to be disabled?

Even a JavaScript virgin like me can answer that. Just look on the menu
items of your browser; you are almost guaranteed to find clickable items
that are greyed out.

I've long campaigned that such disabled items should not actually be
rendered completely inoperative; rather they should generate some sort
of information panel (a tooltip would usually be sufficient) describing
exactly why they are greyed out, and the first step that you have to
take in getting them enabled (you only have to document the first step,
as the user can do this, then go back to discover what to do next).

I realise that many of these tooltips would contain little more than
"This control makes no sense in this context", but at least my
suggestion would save a few of us from having an apoplexy whilst
grappling with an unco-operative PC!

As you can see, not one single developer has risen to my challenge...
Not even the ones whose sales would benefit from tooltips that said "In
order to activate this control you have to buy Product X"
 
E

Evertjan.

Steve Swift wrote on 22 sep 2007 in comp.lang.javascript:
This my be a stupid question by why would you bother to provide a
link in the first place if you intend for it to be disabled?

Even a JavaScript virgin like me can answer that. Just look on the
menu items of your browser; you are almost guaranteed to find
clickable items that are greyed out. [..]
As you can see, not one single developer has risen to my challenge...
Not even the ones whose sales would benefit from tooltips that said
"In order to activate this control you have to buy Product X"

Seems simple enough to make it yourself:

=====================================
<script type='text/javascript'>
var greyed = true;
//var greyed = false; // remove first // for testing not-greyed
</script>

<a href='http://cnn.com'
onclick='return !greyed;'
onmouseover='this.title=(greyed)?"No go, sorry!":"Go.";'
title='Go.'
test me</a>
=====================================

I did not bother with an actual "greying",
just with the disabling and tooltipping.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top