I'm making a site that needs to be totally accessable to blind users, but have a few flashy DHTML effects for browsers that know what to do with them. One thing I want to do is have a javascript modify all the links after the page loads to remove their href attributes and add an onClick handler. If the browser doesn't support DHTML, this won't occur, leaving the static links in place. I don't use Javascript heavily, so I usually have to RTFM any time I want to do something fancy.
From what I can tell, there's no way to unset the href attribute (or anything else). I can set it to "#", but that makes some browsers jump to the top of the screen, which isn't what I want. I could use an onFocus handler, but I want it to respond to a click, not a rollover. I really want to eliminate the href. Lacking a way to do that, I decided to just replace the link by creating a new Anchor object and setting the element to that object. There's just one problem: no browser that anybody actually uses supports making anchor objects at runtime.
There's a delete function for removing values from arrays, and I've seen several places that you should be able to unset something with foo=undefined. Both of these fail to have the desired effect on anchor objects.
I've heard Javascript described as Scheme with C syntax, but right now I feel like I'm using Intercal. I'm probably missing something obvious, but I don't know where to look.
last updated 2 years ago #
