JavaScript Bible, Gold Edition part 143

JavaScript Bible, Gold Edition part 143. This book will bring programmers and non-technical professionals, including casual programmers and scripters, painlessly up to speed on all aspects of mastering JavaScript. Key topics include programming fundamentals, JavaScript language elements and how to use them effectively, and how to easily and efficiently add powerful new functionality to HTML documents and Java applets. | 1268 Part V Putting JavaScript to Work this case or until it is set by script is an empty string. IE5 provides a currentStyle property to give us the effective values but that property is not yet a part of the DOM standard. But even if you assign the style sheet via the element s STYLE attribute in which case the style property values come through detecting the presence of the property with the conditional expression if is not practical here anyway. If the effective value of the left and top properties were an empty string or zero for a numeric style property value the conditional expression would evaluate to the equivalent of false making it appear as though the property doesn t exist. To validate the existence of the property the conditional expression verifies that the value of a named property has a type other than undefined. It may seem like a long way to go to prove the existence of a property but it works even if the value is an empty string or zero. It is important that both branches perform object detection. Although it is unlikely but as we learned from the transition between NN4 and NN6 not impossible if a future browser should completely alter its vocabulary omitting the objects being detected here the function ends gracefully without generating script errors. An API is usually best deployed as an external .js file. One such API file is described later in this chapter. Bear in mind however that a lengthy API gets downloaded to the browser no matter how much or how little of it your main scripts use. Blindly linking in a big library just to use a few of its functions is a mistake. You serve your users better if you create a subset of the API and link the subset to the page or drop the few functions directly into the page s scripts if the combination is not reused on a lot of pages . Handling non-DHTML browsers An important question to ask yourself as you embark on a DHTML-enhanced page is how you intend to treat visitors whose browsers aren t

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
10    93    2    23-06-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.