JavaScript Bible, Gold Edition part 190. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | CD-382 Part VI Appendixes Example Use The Evaluator to test out the getElementsByName method. All form elements in the upper part of the page have names associated with them. Enter the following statements into the top text field and observe the results speed .length speed 0 .value You can also explore all of the properties of the text field by typing the following expression into the bottom field speed 0 getSelection NN2 NN3 NN4 NN6 IE3 J1 IE3 J2 IE4 IE5 Compatibility Example The document in Listing 18-15 provides a cross-browser but not IE5 Mac solution to capturing text that a user selects in the page. Selected text is displayed in the textarea. The script uses browser detection and branching to accommodate the diverse ways of recognizing the event and reading the selected text. Listing 18-15 Capturing a Text Selection HTML HEAD TITLE Getting Selected Text TITLE SCRIPT LANGUAGE JavaScript var isNav4 Netscape parseInt 4 var isNav4Min Netscape parselnt 4 var isIE4Min Microsoft -1 parselnt 4 function showSelection if isNav4Min 0 . else if isIE4Min Appendix F Examples from Parts III and IV CD-383 if 0 . .text true if isNav4 showSelection SCRIPT HEAD BODY H1 Getting Selected Text H1 HR P Select some text and see how JavaScript can capture the selection P H2 ARTICLE I H2 P Congress shall make no law respecting an establishment of religion or prohibiting the free exercise thereof or abridging the freedom of speech or of the press or the right of the people peaceably to assemble and to petition the