Đang chuẩn bị liên kết để tải về tài liệu:
Học JavaScript qua ví dụ part 56

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Vị trí con chuột Chúng tôi dành toàn bộ một phần của chương này để xử lý xử lý sự kiện chuột và những gì xảy ra nếu cuộn chuột lên một liên kết hoặc hình ảnh. Trong phần này chúng tôi thảo luận làm thế nào để tìm ra những sự kiện chuột kích hoạt và nơi chuột được bố trí khi bị sa thải. Đối với các trình duyệt tương thích nhìn thấy bảng http://www.quirksmode.org/dom/w3c_cssom.html | 508 Chapter 13 Handling Events Figure 13.35 Firefox The mouse was clicked in the textbox but captured first in the form. Figure 13.36 Firefox A key was pressed in the textbox. 13.7.5 Mouse Positions We devoted a whole section of this chapter to handling mouse event handlers and what happens if the mouse rolls over a link or an image. In this section we discuss how to find out what event the mouse triggered and where the mouse was positioned when it fired. For browser compatibility tables see http www.quirksmode.org dom w3c_cssom.html. Mouse Position. The client X and clientY properties Internet Explorer and pageX and pageY properties Firefox are used to get the coordinate positions of the mouse pointer in the document when the event is triggered. If you want to get the coordinate positions of the mouse within an element then you would use the offsetX and offsetY properties Internet Explorer and nonstandard layerX and layerY Firefox . From the Library of WoweBook.Com 13.7 The event Object 509 EXAMPLE 13.23 html head title Mouse Coordinates title script type text javascript function getCoords e 1 var x 0 x and y positions var y 0 2 if e var e window.event Internet Explorer 3 if e.pageX e.pageY Firefox x e.pageX y e.pageY 4 else if e.clientX e.clientY 5 x e.clientX document.body.scrollLeft document.documentElement.scrollLeft y e.clientY document.body.scrollTop document.documentElement.scrollTop x and y contain the mouse position relative to the document alert x y script head body div style background-color aqua position absolute top 50px onMouseover return getCoords event h1 Mouse positions are relative to the document not the lt div gt container h1 div body html EXPLANATION 1 Variables x and y are declared. They will hold the pixel coordinates of the mouse. 2 If using Mozilla Firefox the value of e will be sent to the function if using Internet Explorer the value of window.event will be assigned to e. In this way both browsers will get a reference to the event .

Đã 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.