make focusable element unfocusable on webkit
Posted
by Bill Keese
on Stack Overflow
See other posts from Stack Overflow
or by Bill Keese
Published on 2010-04-29T08:13:00Z
Indexed on
2010/04/29
8:17 UTC
Read the original article
Hit count: 502
When a node has a tabIndex setting (other than -1), clicking it will give it focus. Removing the tabIndex setting should stop that behavior, so that clicking has no effect.
However, on webkit, once a node has a tabIndex, even after tabIndex is removed, the node can still be clicked and focused. Setting tabIndex=-1 also has the same click problem.
Anyone know a workaround to this problem?
<div id="one">one (no initial tabindex)</div>
<div id="two" tabindex=0>two (initially tabindex=0)</div>
<button type=button onclick="document.getElementById('one').setAttribute('tabindex', 0)">set tabindex on first div</button>
<button type=button onclick="document.getElementById('one').removeAttribute('tabindex', 0)">remove tabindex on first div</button>
<button type=button onclick="document.getElementById('two').removeAttribute('tabindex', 0)">remove tabindex on second div</button>
<button type=button onclick="document.getElementById('one').setAttribute('tabindex', -1)">set tabindex=1 on first div</button>
<button type=button onclick="document.getElementById('two').setAttribute('tabindex', -1)">set tabindex=1 on second div</button>
© Stack Overflow or respective owner