[thelist] Removing a link with JavaScript.

Ben Henick persist1 at io.com
Mon Nov 18 07:28:01 CST 2002


On Mon, 18 Nov 2002, Chris Marsh wrote:

> Why would you want to hardcode a link that only actually links when the
> keyboard is used to navigate? I suspect you're actually trying to
> achieve something else that can probably be done using a different
> method...
...
> >
> > Is it possible?
>
> I'm pretty sure that if you include onclick='return false;' in the
> anchor tag you will achieve what you appear to want. Why not give us
> some context?

As regards the desired solution...

You can manipulate the markup itself by changing its outerHTML property,
or the innerHTML property of its parent element.  That will only work on
IE, though.

Or you can accomplish the same thing with compliant code, which requires a
slightly more circuitous approach if the link you need to change is buried
in the document stucture.

I personally think you might want to consider the alternative of just
using CSS to style that particular link so that it's indistinguishable
from normal copy (which means fiddling with the pointer that results
onmouseover as well).  Then using JavaScript, go ahead and put another
style declaration behind the link's onfocus event, meaning that if a
keyboard users tabs to it, it will behave like a link more-or-less.

However, I have to agree that you might want to take a closer look at the
UI implementation... the objective risks breaking consistency in a
potentially nasty way, an outcome to be avoided.


--
Ben Henick
Web Author At-Large              Associate Editor
http://www.io.com/persist1/      http://www.digital-web.com/
persist1 at io.com                  bmh at digital-web.com
--
"Are you pondering what I'm pondering, Pinky?"
"I think so, Brain, but... (snort) no, no, it's too stupid."
"We will disguise ourselves as a cow."
"Oh!" (giggles) "That was it exactly!"





More information about the thelist mailing list