Phát triển Javascript - part 25

Tham khảo tài liệu 'phát triển javascript - part 25', 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 Feature Detection 213 return event element listener return _addEventHandler element event listener addEventHandler The mouseenter implementation keeps track of whether the mouse is currently hovering the target element and fires anytime a mouseover is fired and the mouse wasn t previously hovering it. The method uses parent child which returns true if an element contains another. The try-catch protects against a bug in Firefox which will sometimes provide an XUL element as relatedTarget. This can happen when mousing over for instance a scroll bar and unfortunately XUL elements throw exceptions on any property access. Additionally the relatedTarget may be a text node fetching its parentNode gets us back on track. To practice feature detection I encourage you to take this method for a spin find more browser quirks and smooth them over by detecting erroneous behavior and correcting it. Using Feature Detection Feature detection is a powerful tool in cross-browser scripting. It can allow many features to be implemented for a very wide array of browsers old current and future ones. That does not necessarily mean that employing feature detection implies that you should provide fallback solutions for any feature that may not be supported. Sometimes dropping support for old browsers can be a statement in itself but we should be able to do so without sniffing out the browsers we want to send down the degradation path. Moving Forward If supporting a troublesome old browser oh say Internet Explorer 6 costs more than the benefits can defend businesses sometimes actively decide to drop support. Doing so does not mean we should pretend unsupported browsers don t exist. Using unobtrusive JavaScript and feature detection can ensure that when a browser is no longer actively developed for it will receive the usable but possibly Download from 214 Feature Detection basic fallback solution. In such

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã 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.