TAILIEUCHUNG - JavaScript Bible, Gold Edition part 171

JavaScript Bible, Gold Edition part 171. 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-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 TextRectangle objects 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 left and right properties from the chosen rectangle in the clientRects array. Next comes the assignment of location and dimension values to the hiliter object s style property. The top and bottom are always pegged to whatever line is selected so the clientRects array is polled for the chosen entry s top and bottom properties. The previously calculated left value is assigned to the hiliter object s pixelLeft property while the width is calculated by subtracting the left from the right coordinates. Notice that the top and 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 onResize event handler applies the currently chosen line number to whatever content falls in that line after resizing. Listing 15-27 Using getBoundingClientRect HTML HEAD TITLE getClientRects and getBoundClientRect Methods TITLE SCRIPT LANGUAGE JavaScript function hilite var hTop hLeft hRight hBottom hWidth var select 0 .choice var n parseInt .value - 1 var clientRects var mainElem if n 0 n .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.