| 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" |
|---|
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
|---|
| 3 | |
|---|
| 4 | <html> |
|---|
| 5 | |
|---|
| 6 | <head> |
|---|
| 7 | <title>tabindex and focus</title> |
|---|
| 8 | <style type="text/css"> |
|---|
| 9 | div, input, img { |
|---|
| 10 | border-color: #000; |
|---|
| 11 | border-style: solid; |
|---|
| 12 | } |
|---|
| 13 | div, img { |
|---|
| 14 | border-width: 0px; |
|---|
| 15 | } |
|---|
| 16 | input { |
|---|
| 17 | border-width: 1px; |
|---|
| 18 | margin: 5px; |
|---|
| 19 | } |
|---|
| 20 | div.focused, input.focused, img.focused { |
|---|
| 21 | border-width: 5px; |
|---|
| 22 | } |
|---|
| 23 | </style> |
|---|
| 24 | <script type="text/javascript"> |
|---|
| 25 | function focusElem(id){ |
|---|
| 26 | setTimeout(function(){ |
|---|
| 27 | document.getElementById(id).focus(); |
|---|
| 28 | }, 0); |
|---|
| 29 | } |
|---|
| 30 | function highlight(elem){ |
|---|
| 31 | elem.className = "focused"; |
|---|
| 32 | } |
|---|
| 33 | function unhighlight(elem){ |
|---|
| 34 | elem.className = ""; |
|---|
| 35 | } |
|---|
| 36 | </script> |
|---|
| 37 | </head> |
|---|
| 38 | |
|---|
| 39 | <body> |
|---|
| 40 | |
|---|
| 41 | <div id="div-no-tabindex" onfocus="highlight(this)" onblur="unhighlight(this)" |
|---|
| 42 | >div no tabindex</div> |
|---|
| 43 | <div id="div-tabindex-minus-1" tabindex="-1" onfocus="highlight(this)" |
|---|
| 44 | onblur="unhighlight(this)">div tabindex="-1"</div> |
|---|
| 45 | <div id="div-tabindex-0" tabindex="0" onfocus="highlight(this)" |
|---|
| 46 | onblur="unhighlight(this)">div tabindex="0"</div> |
|---|
| 47 | |
|---|
| 48 | <p> |
|---|
| 49 | <input id="input-no-tabindex" value="input no tabindex" |
|---|
| 50 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 51 | <br> |
|---|
| 52 | <input id="input-tabindex-minus-1" tabindex="-1" |
|---|
| 53 | value='input tabindex="-1"' |
|---|
| 54 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 55 | <br> |
|---|
| 56 | <input id="input-tabindex-0" tabindex="0" value='input tabindex="0"' |
|---|
| 57 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 58 | </p> |
|---|
| 59 | |
|---|
| 60 | <p> |
|---|
| 61 | img no tabindex: <img id="img-no-tabindex" src="greenbox.png" alt="green box" |
|---|
| 62 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 63 | <br> |
|---|
| 64 | img tabindex="-1": <img id="img-tabindex-minus-1" src="greenbox.png" |
|---|
| 65 | alt="green box" tabindex="-1" |
|---|
| 66 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 67 | <br> |
|---|
| 68 | img tabindex="0": <img id="img-tabindex-0" src="greenbox.png" alt="green box" |
|---|
| 69 | tabindex="0" |
|---|
| 70 | onfocus="highlight(this)" onblur="unhighlight(this)"> |
|---|
| 71 | </p> |
|---|
| 72 | |
|---|
| 73 | <hr> |
|---|
| 74 | |
|---|
| 75 | <div> |
|---|
| 76 | <button onclick='focusElem("div-no-tabindex")'>focus div no tabindex</button><br> |
|---|
| 77 | <button onclick='focusElem("div-tabindex-minus-1")'>focus div tabindex="-1"</button><br> |
|---|
| 78 | <button onclick='focusElem("div-tabindex-0")'>focus div tabindex="0"</button><br> |
|---|
| 79 | <button onclick='focusElem("input-no-tabindex")'>focus input no tabindex</button><br> |
|---|
| 80 | <button onclick='focusElem("input-tabindex-minus-1")'>focus input tabindex="-1"</button><br> |
|---|
| 81 | <button onclick='focusElem("input-tabindex-0")'>focus input tabindex="0"</button><br> |
|---|
| 82 | <button onclick='focusElem("img-no-tabindex")'>focus img no tabindex</button><br> |
|---|
| 83 | <button onclick='focusElem("img-tabindex-minus-1")'>focus img tabindex="-1"</button><br> |
|---|
| 84 | <button onclick='focusElem("img-tabindex-0")'>focus img tabindex="0"</button> |
|---|
| 85 | </div> |
|---|
| 86 | |
|---|
| 87 | </body> |
|---|
| 88 | |
|---|
| 89 | </html> |
|---|