TAILIEUCHUNG - DHTML Utopia Modern Web Design Using JavaScript & DOM- P11

DHTML Utopia Modern Web Design Using JavaScript & DOM- P11:In a single decade, the Web has evolved from a simple method of delivering technical documents to an essential part of daily life, making and breaking relationships and fortunes along the way. “Looking something up on the Internet,” by which is almost always meant the Web, is now within reach of almost anyone living in a first-world country, and the idea of conducting conversations and business (and probably orchestras) in your Web browser is no longer foreign, but part of life | Chapter 7 Advanced Concepts and Menus function mover e var el e null . This works fine for browsers that support the standard event model but remember that Internet Explorer doesn t. And although IE uses as equivalent to the standard target property IE has no equivalent to the currentTarget property. In order to get the element to which the event listener was assigned in IE we ll have to be slightly more creative. Instead of using the mover and mout functions directly as the mouse event listeners for all of the submenu headers we ll create a custom pair of listener functions for each one. Those custom listener functions will in turn call mover and mout but will pass them the reference to the particular li that we need. Let s look at the code changes. First in our init function we alter the addEvent calls that assign our event listeners File excerpt addEvent node mouseover getMoverFor node false addEvent node mouseout getMoutFor node false Instead of assigning mover and mout as the listeners we call new functions getMoverFor and getMoutFor. These functions will create custom listener functions for the submenu header in question node File excerpt function getMoverFor node return function e mover e node function getMoutFor node return function e mout e node As you can see getMoverFor and getMoutFor create and return new event listener functions that call mover and mout respectively passing not only the event object but a reference to the submenu header element node. Because this listener function is created inside the getMoverFor getMoutFor function it can access any of the local variables that exist in that environment including the node argument. The act of taking a function that has access to a 180 Licensed to siowchen@ Making Submenus Appear private environment and making it accessible as an event listener from outside that environment is known

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