I met a problem about HTML rendering.
In dir="rtl" document of IE7, when JavaScript tries to set focus to a DIV element(with oElement.focus() method), the rendering turns to mess. The context is very complicated, so I suppose the easiest fix is to make the DIV unfocusable?
Is there any way to make a DIV not be focused?
In order to make an prevent an element from taking focus ("non-focusable"), you need to use Javascript to watch for the focus and prevent the default interaction. In order to prevent an element from being tabbed to, use tabindex=-1 attribute. Adding tabindex=-1 will make any element focusable, even div elements.
To disable focus on a specific element, set the tabIndex property on the element to a value of -1 . The tabIndex property can be used to specify that an element cannot be focused using keyboard navigation. Here is the HTML for the examples in this article.
Yes - this is possible. In order to do it, you need to assign a tabindex...
Add the tabindex="0" attribute to each div you want tabbable. Then use CSS pseudo classes :hover and :focus, for example to signify to the app user that the div is in focus and clickable, for example.
The <div>
should not be capable of receiving focus unless you have added tabIndex.
If you have added tabIndex
, you should remove it by
document.getElementById("yourElement").removeAttribute("tabIndex");
Additionally, If you want to make a focussable element(form input elements etc.) as unfocussable. You can set :
tabIndex = "-1"
document.getElementById("yourElement").setAttribute("tabIndex", "-1");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With