TAILIEUCHUNG - Phát triển Javascript - part 24

Tham khảo tài liệu 'phát triển javascript - part 24', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Using Object Detection for Good 203 Listing Unfriendly Host object behavior TestCase HostObjectTest test IE host object behavior function var xhr new ActiveXObject assertException function if Expectation property exists Reality exception is thrown assertEquals unknown typeof var element div assertEquals unknown typeof assertException function In his article Feature Detection State of the Art Browser Scripting 1 Peter Michaux provides the isHostMethod method shown in Listing to help with feature detection and host methods. Listing Checking if a host object is callable function function isHostMethod object property var type typeof object property return type function type object object property type unknown return isHostMethod 1. http articles feature-detection-state-of-the-art-browser-scripting Download from 204 Feature Detection This method is able to recognize callable host objects based on the following observations ActiveX properties always have a typeof result of unknown. Non-ActiveX callable host objects in Internet Explorer usually have a typeof result of object. The boolean coercion is required to avoid null which also has a typeof result of object. In other browsers callable objects tend to have a typeof result of function even host methods Using this helper we can improve our cross-browser event handler as seen in Listing . Listing Improved feature detection for addEventHandler function addEventHandler element type listener if element addEventListener type listener false else if element attachEvent on type function return element else Possibly fall back to DOM0 event properties or abort Sample Use Testing Testing for the existence and type of an .

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.