I have some questions about focus in general (adhering to WC3 format, screw IE). I'm having problems with unintended actions occurring on a widget i am building (using the Dojo Toolkit), and i believe a better general understanding of focus will allow me to solve my problem myself, so here goes:
First of all, which common HTML element are and AREN'T focusable? I've been trying to throw focus around and it works sometimes, and doesnt work other times...
What is the 'highest' level focusable on a page? For instance, can i focus the window? The <body>
tag? Specific to dojo, can you focus an entire widget? If the template is widgeted can you focus just highest level of the template (usually a <div>
)?
focus()
method on elements, can focus be set through HTML attributes or in a CSS?
Thanks in advance for what i hope to be some great answers!Disabled controls can't receive focus according to the HTML4.01 spec
Firefocus, an extension that works over Firebug, could be a great enhancement if you're asking this sort of questions :) Install, restart and look at the Console
Related to focus is the order in which elements are given the focus, that is the order of tabbing navigation and the
tabindex
attribute with its values -1, 0 or positive when it exists
- Any DOM element can receive focus amongst other some event handlers.
- See answer 1.
- Focus is passed around and not removed.
- Focus can only be set by the DOM using JavaScript.
You can also use dojo.place to put things in the correct for focus.
精彩评论