Web hosting india - CD-192 Part VI . Appendixes invoked for the

CD-192 Part VI . Appendixes invoked for the main element to capture a snapshot of all TextRectangles for the entire element. This array comes in handy when the script needs to get the coordinates of a rectangle for a single line, as chosen in the SELECT element. Whenever the user chooses a number from the SELECT list and the value is less than the total number of TextRectangleobjects in clientRects, the function begins calculating the size and location of the underlying yellow highlighter. When the Full Width checkbox is checked, the left and right coordinates are obtained from the getBoundingClientRect() method because the entire SPAN element s rectangle is the space you re interested in; otherwise, you pull the leftand right properties from the chosen rectangle in the clientRects array. Next comes the assignment of location and dimension values to the hiliter object s styleproperty. The top and bottom are always pegged to whatever line is selected, so the clientRects array is polled for the chosen entry s topand bottom properties. The previously calculated leftvalue is assigned to the hiliterobject s pixelLeftproperty, while the width is calculated by subtracting the leftfrom the right coordinates. Notice that the topand left coordinates also take into account any vertical or horizontal scrolling of the entire body of the document. If you resize the window to a smaller size, line wrapping throws off the original line count. However, an invocation of hilite()from the onResizeevent handler applies the currently chosen line number to whatever content falls in that line after resizing. Listing 15-27: Using getBoundingClientRect() getClientRects() and getBoundClientRect() Methods