TAILIEUCHUNG - the book of javascript 2nd edition phần 2

Sách được chia làm 5 phần rõ ràng gồm: Tổng quan về JavaScript, Sử dụng JavaScript, Hàm và đối tượng, Tạo đối tượng trong JavaScript, Sự kiện trong JavaScript. | writes whatever lies between the parentheses to the web page. Before diving into the date functions that you ll need to write the date to your web page I ll talk about two interesting functions just so you get the hang of how functions work. alert One handy function is alert which puts a string into a little announcement box also called an alert box . Figure 2-7 demonstrates how to call an alert and Figure 2-8 shows what the alert box looks like. html head title An Alert Box title script type text javascript -- hide me from older browsers o alert This page was written by thau show me -- script body h1 To code perchance to function h1 body html Figure 2-7 Creating an alert box The first thing visitors see when they come to the page Figure 2-7 creates is an alert box announcing that I wrote the page Figure 2-8 . The alert box appears because of o which tells JavaScript to execute its alert function. While the alert box is on the screen the browser stops doing any work. Clicking OK in the alert box makes it go away and allows the browser to finish drawing the web page. In this case that means writing the words To code perchance to function Figure 2-8 The alert box to the page . The alert function is useful for troubleshooting when your JavaScript isn t working correctly. Let s say you ve typed in Figure 2-6 but when you run the code you see that you must have made a typo it says there are 0 seconds in a day instead of 86400. You can use alert to find out how the different variables are set before multiplication occurs. The script in Figure 2-9 contains an error that causes the script to say there are undefined seconds in a year and to track down the error I ve added alert function statements that tell you why this problem is occurring. 22 Chopter 2 html head title Seconds in a Day title script type text javascript -- hide me from older browsers var seconds_per_minute 60 var minutes_per_hour 60 o var Hours_per_day 24 alert seconds per minute is seconds_per_minute alert

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.