Web Programming with HTML, XHTML, and CSS Second Edition- P10

Web Programming with HTML, XHTML, and CSS Second Edition- P10: Điều này bắt đầu hướng dẫn nhận xét HTML và cũng giới thiệu đến bạn bằng cách sử dụng XHTML cho cấu trúc của một trang web và cascading style sheets (CSS) để kiểm soát như thế nào một tài liệu sẽ xuất hiện trên một trang web. Bạn se tìm hiểu làm thế nào để tận dụng lợi thế của các tính năng mới của các trình duyệt trong khi đảm bảo rằng các trang của bạn vẫn làm việc ở cũ, nhưng phổ biến, các trình duyệt. Bằng. | Chapter 11 Learning JavaScript 4. Save this example as and open it in your browser. Then roll your mouse over the image without clicking it . You should see something like Figure 11-5 with the mouse over the image. Figure 11-5 How It Works When the user rolls over the image the onmouseover event fires and when the user moves off it again the onmouseout event fires. This is why there are separate attributes that correspond to each of these events and when one of these two events fires the script held as a value for the corresponding attribute is executed. The script in the onmouseover and onmouseout event handler attributes tells the browser to change the src attribute of the image and therefore a different image is displayed to the user. The first onmouseover indicates what should happen when the mouse is placed over the image the second onmouseout indicates what should be done when the mouse is moved off the image. You can see in the code for that when the user puts the mouse over an image the src property of the image inside the link named using the notation is changed. a href onmouseover onmouseout img src width 100 height 50 border 0 name button a The img element must have a name attribute so that the image can be referenced in this way in the link otherwise you would have to use its index in the images collection . It is generally best to use the name in situations like this rather than the index of that image in the images collection because if you were to add another image into the document before this one the whole script would need changing. Note that if no event indicated what should happen when the user takes the mouse off the image it would remain red rather than turning back to green. An image rollover script is a good example of changing or setting that property rather than just reading it. You learn .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
10    94    3    29-04-2024
Đã 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.