TAILIEUCHUNG - Beginning JavaScript Third Edition phần 9

Sửa chữa các sai lầm và nạp lại trang, bạn sẽ thấy bảng hai lần trong trang web của bạn, như thể hiện trong hình 10-11. Trong các chức năng window_onload (), bạn lần đầu tiên xác định một biến, plugInInstalled, và khởi tạo nó sai., kiểm tra mỗi tên của plug-in được cài đặt RealPlayer từ. Nếu | Chapter 15 Using ActiveX and Plug-Ins with JavaScript if plugInCounter . RealPlayer 0 plugInInstalled true break else if 4 plugInInstalled true if plugInInstalled false script head body onload return window_onload noembed h2 This Page requires a browser supporting Plug-ins or ActiveX controls h2 noembed body html In the window_onload function you first define a variable plugInInstalled and initialize it to false. Next since checking for plug-ins or controls is browser-dependent you check to see if this is a Microsoft browser. If not you assume it s Firefox though for a real-life example you might want to do more detailed checks. If the browser is Firefox you use a for loop to go through the navigator object s plugins array checking each installed plug-in s name for the word RealPlayer. If this word is found you set the variable plugInInstalled to true and break out of the for loop. If you find that this is a Microsoft browser you use the readyState property of the object element s Object object to see if the ActiveX control is loaded initialized successfully and now ready for action. If its value is 4 you know that all systems are ready to go and you can use the control so you set the variable plugInInstalled to true. Finally the last if statement in the function checks to see if plugInInstalled is true or false. If it is false the user is redirected to another page called where you can either provide alternative ways to display the content or provide a link to load the RealPlayer control. Let s create a simple page to do this. html head title No Real Player Installed title head 609 Chapter 15 Using ActiveX and Plug-Ins with JavaScript body h2 You don t have the required RealPlayer plug-in h2 p You can download the plug-in from a href http Real Player a p body html Save this as . Finally back in the page .

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.