Posted by Steve Pugh on 11/22/16 11:40
Stefan Mueller wrote:
> This html code should demonstrate my problems with 'tabindex':
> <img src= 'pic23.gif' tabindex = '0'>
> <input type = 'text'>
> <p>
> <img src= 'pic12.gif' tabindex = '0'>
> <input type = 'text'>
> <p>
> <img src= 'pic25.gif' tabindex = '0'>
> <input type = 'text'>
Why are you placing the tabindex attribute on the image and not on the
form input?
> In my project I have on each row a picture and a textbox. The sequencing of
> the rows is randomized because I use some sort of algorithm programmed with
> JavaScripts.
>
> 1) My goal is that if you load/reload the page the cursor is always located
> at the first image (most top and left) independent of how the rows are
> sorted.
> How can I locate the cursor always to the first image? I guess somehow
> with
> <body onLoad = "...">
Assuming that you do/will assign an id to each image, then in theory:
document.getElementById(imageId).focus()
But giving focus to images may or may not be possible in various
browsers.
But please reconsider this. If the page is slow to load the user may
already have moved the focus and started some action (typing in an
input field for example) before your script moves the focus - screwing
up whatever it was they were doing.
> 2) I'd like that the cursor is going by pressing the 'Tab' key from the
> first image to the textbox on its right side and then to the second image
> and so on.
> For that reason I use
> tabindex = '0'
> That works fine with Mozilla Firefox and with the Internet Explorer .
> However, if you click with your mouse on an image then with Internet
> Explorer (with Mozilla Firefox it works perfect) you have to press the 'Tab'
> key twice to get to the next textbox.
> Why that and does anyone know a workaround so that one 'Tab' would be
> enough to go to the next textbox?
Get rid of the tabindex on the images?
> 3) In Opera the cursor is never located on an image even not if you press
> the 'Tab' key several times.
> Is there another possibility to show an image with Opera which gets the
> focus and which has an 'onBlur' event, so that I know when the cursor leaves
> the image?
Opera separates the form element cycle (accessed via tab) and the link
cycle (accessed via Q/A). (And then there's spatial navigation on top
of that.) If your image isn't a link then I'm not sure how to give it
focus with the keyboard in Opera.
Steve
Navigation:
[Reply to this message]
|