TAILIEUCHUNG - Học php, mysql và javascript - p 33

Sử dụng Scripts Trong thời hạn một Trưởng Tài liệu Ngoài việc đặt một kịch bản trong cơ thể của một tài liệu, bạn có thể đặt nó trong phần , là nơi lý tưởng nếu bạn muốn thực hiện một kịch bản khi tải trang. Nếu bạn đặt mã quan trọng và các chức năng đó, bạn cũng có thể đảm bảo rằng họ đã sẵn sàng để sử dụng ngay lập tức bởi bất kỳ phần kịch bản khác trong tài liệu dựa trên chúng. . | Figure 14-1. JavaScript enabled and working Figure 14-2. JavaScript has been disabled Using Scripts Within a Document Head In addition to placing a script within the body of a document you can put it in the head section which is the ideal place if you wish to execute a script when a page loads. If you place critical code and functions there you can also ensure that they are ready to use immediately by any other script sections in the document that rely on them. Another reason for placing a script in the head is to enable JavaScript to write things such as meta tags into the head section because the location of your script is the part of the document it writes to by default. Older and Nonstandard Browsers If you need to support browsers that do not offer scripting you will need to use the HTML comment tags -- and -- to prevent them from encountering script code that they should not see. Example 14-2 shows how you add them to your script code. Example 14-2. The Hello World example modified for nonJavaScript browsers html head title Hello World title head body script type text javascript Hello World JavaScript and HTML Text 301 -- script body html Here an opening HTML comment tag -- has been added directly after the opening script . statement and a closing comment tag -- directly before the script is closed with script . The double forward slash is used by JavaScript to indicate that the rest of the line is a comment. It is there so that browsers that do support JavaScript will ignore the following -- but non-JavaScript browsers will ignore the preceding and act on the -- by closing the HTML comment. Although the solution is a little convoluted all you really need to remember is to use the two following lines to enclose your JavaScript when you wish to support very old or nonstandard browsers script type text javascript -- Your JavaScript goes here. -- script However the use of these comments is unnecessary for any browser released over the past .

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.