Forum Moderators: open

Message Too Old, No Replies

Setting or holding keyboard navigation focus position

with your CSS toggle switch?

         

MarcMiller

9:39 am on Feb 1, 2006 (gmt 0)

10+ Year Member



Hi- I thought it might be nice if I could devise a method to get stronger visual indication when somebody is keyboard navigating a site. It seems to me that those little dotted lines is very weak visual indication, even to somebody with good eyesight and certainly to someone with poor eyesight. So a method of stronger visual indication was needed in my opinion. So I was thinking if say one could change background color of the parent li tag of the link tag (<a>) styled as a CSS button one would have strong visual indication for that button when keyboard navigating. I tried it it worked, but there's a bug. I am using one of my pure CSS switches as a toggle switch to turn on and off the slide advancement of a timed JavaScript slideshow. So my switch is a toggle switch. When the switch toggles the focus of my switch is lost and seems to end up in the browser address window. I wanted to end up back on my switch with the change background color of the parent li tag maintained. This does not happened so does anyone here have any ideas on how I can make it happen with a little more code. The relevant HTML and JavaScript follows. I am not including my CSS since it is not relevant to this question. Your ideas would be greatly appreciated.
Sincerely Marc

PS I know removing the call of "changeParentColorOff(this)", in the onclick event handler, will fix this problem, but that is not an option since the change background color is only supposed to be a feature of keyboard navigating and not mouse navigating.

HTML

<body>
<ul>
<li >
<a href="Fantasy_Bob_Home.html"
tabindex="10"
onfocus="changeParentColorOn(this)"
onblur="changeParentColorOff(this)">
Fantasy Bob Home Page return
</a>
</li>
<li id="imageHolderHight"><img src="wedding_HQ/HQ5.jpg"
id="slide" alt="Wedding Slideshow"/>
</li>
<li>
<a href="#" onclick="buttonStateChanger();changeParentColorOff(this)"
tabindex="20"
id="a1" title="Toggling
switch with Toggling switching message"
onfocus="changeParentColorOn(this)"
onblur="changeParentColorOff(this)" >
Click here to stop picture changing
</a>
</li>
</ul>
</body>

Javascript

function changeParentColorOn(passingThis)
{
passingThis.parentNode.style.backgroundColor='#8DACCD';
}
function changeParentColorOff(passingThis)
{
passingThis.parentNode.style.backgroundColor='transparent';
}

MarcMiller

10:25 am on Feb 1, 2006 (gmt 0)

10+ Year Member



Second PS my PS was wrong above. I was a little confused toggling the switch always moves a focus.

Bernard Marx

11:50 pm on Feb 2, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Firstly, I should mention that those modern browsers (ie not IE) support the CSS :focus pseudo-class.

<style>
a.example:focus{background-color: blue;}
</style>
<a href="#" class="example">Focus Me</a>

Your script seems to work OK, so I'm a little confused about the rest, Marc.

DrDoc

5:56 am on Feb 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, IE doesn't support a:focus, but it does apply the a:active styles when keeping tab focus.