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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JS styleswitcher buggy in Firefox/Opera

Status
Not open for further replies.

Loquela

Programmer
Mar 15, 2007
2
GB
Hi there,

I posted this problem on another forum and although more than 30 people looked at it there wasn't a single reply. Have I really discovered an unsolvable Javascript problem?

I'm an absolute novice at javascript so please be gentle.
I am using a js styleswitcher to offer alternative displays.
The menu that links to the script that does the job looks like this:


Code:
*****************************************************
<ul>
<li><a href="#content" tabindex="1" >Skip to Content:</a></li>
<li><a href="accessibility_help.php" title="Read our Accessibility Policy">Accessibility Help:</a></li>
<li><a href="#" onclick="setActiveStyleSheet('default');return false;" onkeypress="setActiveStyleSheet('default'); return false;" title="Default Page Style">DEFAULT</a></li>
<li><a href="#" onclick="setActiveStyleSheet('hicontrast');return false;" onkeypress="setActiveStyleSheet('hicontrast'); return false;" title="High Contrast Version">HI CONTRAST</a></li>
<li><a href="#" accesskey="t" onclick="setActiveStyleSheet('textonly');return false;" onkeypress="setActiveStyleSheet(textonly'); return false;" title="Text Only Version">TEXT ONLY</a></li>
</ul>

**************************************************

The switcher works perfectly in all browsers but in Firefox and Opera it seems to be interfering with the ability to tabindex. I am guessing it is the way these browsers handle onkeypress or return false rather that an error in the js switcher itself. This is a problem because the reason I am implimenting the switcher in the first place is for accessibility reasons.

Does anyone have any ideas?

Loquela
 
Remove the onkeypress events you have on the anchors. If you are tabbing through the nodes, then you would trigger the anchor using, say, the space key (and this may vary from OS and browser - but the person using the browser will be familiar with it - if they use this feature in the first place).

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Thanks for that Jeff!

Perfect solution.

Simon
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top