256Part IIIDocument (Web design tools) Objects ReferenceIn Internet Explorer, you can

256Part IIIDocument Objects ReferenceIn Internet Explorer, you can remove an element from tabbing order entirely by setting itstabIndexproperty to -1. Users can still click those elements to make changes to form ele- ment settings, but tabbing bypasses the element. ExampleListing 15-16 contains a sample script that demonstrates how to control the tab order of aform via the tabIndexproperty. This example not only demonstrates the way you can mod- ify the tabbing behavior of a form on the fly but also how to force form elements out of thetabbing sequence entirely in IE. In this page, the upper form (named lab) contains four ele- ments. Scripts invoked by buttons in the lower form control the tabbing sequence. Noticethat the tabindexattributes of all lower form elements are set to -1, which means that thesecontrol buttons are not part of the tabbing sequence in IE. When you load the page, the default tabbing order for the labform control elements (defaultsetting of zero) takes charge. If you start pressing the Tab key, the precise results at firstdepend on the browser you use. In IE, the Address field is first selected; next the Tab sequencegives focus to the window (or frame, if this page were in a frameset); finally the tabbing reachesthe labform. Continue pressing the Tab key and watch how the browser assigns focus to eachof the element types. In NN6+, however, you must click anywhere on the content to get the Tabkey to start working on form controls. The sample script inverts the tabbing sequence with the help of a forloop that initializes twovariables that work in opposite directions as the looping progresses. This gives the last elementthe lowest tabIndexvalue. The skip2()function simply sets the tabIndexproperty of thesecond text box to -1, removing it from the tabbing entirely (IE only). Notice, however, that youcan click in the field and still enter text. (See the disabledproperty earlier in this chapter tosee how to prevent field editing.) NN6+ does not provide a tabIndexproperty setting thatforces the browser to skip over a form control. You should disable the control instead. Listing 15-16: Controlling the tabIndex Property