Web server certificate - 272Part IIIDocument Objects Referencebeginning. Browsers prior to IE4
Friday, November 23rd, 2007272Part IIIDocument Objects Referencebeginning. Browsers prior to IE4 and NN6 limited these methods primarily to the windowobject and form control elements. WindowsFor window objects, the blur()method (NN3+, IE4+) pushes the referenced window to theback of all other open windows. If other browser suite windows (such as e-mail or newsreader windows) are open, the window receiving the blur()method is placed behind thesewindows as well. The window.blur()method does not adjust the stacking order of the current window inMozilla-based browsers (thus the Put Me in Back button in Listing 15-23 doesn t work inthose browsers). But a script in a window can invoke the focus()method of another windowto bring that other window to the front (provided a scriptable linkage, such as the window. openerproperty, exists between the two windows). The minute you create another window for a user in your Web site environment, you mustpay attention to window layer management. With browser windows so easily activated by theslightest mouse click, a user can lose a smaller window behind a larger one in a snap. Mostinexperienced users don t think to check the Windows taskbar or browser menu bar (if thebrowser is so equipped) to see if a smaller window is still open and then activate it. If thatsubwindow is important to your site design, then you should present a button or otherdevice in each window that enables users to safely switch among windows. The window. focus()method brings the referenced window to the front of all the windows. Rather than supply a separate button on your page to bring a hidden window forward, youshould build your window-opening functions in such a way that if the window is alreadyopen, the function automatically brings that window forward (as shown in Listing 15-23). Thisremoves the burden of window management from your visitors. The key to success with this method is making sure that your references to the desired win- dows are correct. Therefore, be prepared to use the window.openerproperty to refer to themain window if a subwindow needs to bring the main window back into focus. Form control elementsThe blur()and focus()methods apply primarily to text-oriented form controls: text input, select, and textareaelements. Just as a camera lens blurs when it goes out of focus, a text object blurs when it losesfocus when someone clicks or tabs out of the field. Under script control, blur()deselectswhatever may be selected in the field, and the text insertion pointer leaves the field. Thepointer does not proceed to the next field in tabbing order, as it does if you perform a blur bytabbing out of the field manually. For a text object, having focus means that the text insertion pointer is flashing in that textobject s field. Giving a field focus is like opening it up for human editing. Setting the focus of a text field or textareadoes not, by itself, enable you to place the cursorat any specified location in the field. The cursor usually appears at the beginning of the text. To prepare a field for entry to remove the existing text, use both the focus()and select() methods in series. There is a caveat about using focus()and select()together to preselect the content of atext field for immediate editing: Many versions of Internet Explorer fail to achieve the desiredresults due to an internal timing problem. You can work around this problem (and remainCautionelementObject.blur()