TAILIEUCHUNG - Beginning XML with DOM and Ajax From Novice to Professional phần 3

• Bao gồm JavaScript trong trang của bạn • Nhúng thông tin quảng cáo • Bao gồm các yếu tố không được hỗ trợ và các thuộc tính Trong phần này, tôi sẽ chỉ cho bạn một số lời khuyên thiết thực để giải quyết những vấn đề này. | CHAPTER 3 WEB VOCABULARIES 71 Including JavaScript in your page Embedding advertising information Including unsupported elements and attributes In this section I ll show you some practical tips to address these issues. Many of these tips may be helpful when working with other web vocabularies. Including JavaScript in Your Page For validity it s best to store your JavaScript in a separate file and refer to it with the script element script type text javascript src If you can t avoid embedding JavaScript in an XHTML document place the JavaScript code within a CDATA . element so that it is not interpreted as XHTML by the browser. JavaScript can include characters that otherwise cause the document to fail the well-formed test. Instead of using the following code script type text javascript -- function maxnumber a b if a b then return a if a b then return b if a b then return a -- script rewrite it like this script type text javascript CdAtA function maxnumber a b if a b then return a if a b then return b if a b then return a script 72 CHAPTER 3 WEB VOCABULARIES Embedding Advertising Information Many web sites display advertising information on their pages. If the advertisement isn t valid XHTML you must make sure that you re using the XHTML transitional DTD. You can also add the advertiser information to the page using JavaScript. This ensures that the content displays in the browser but at the same time you can ensure that the XHTML page is valid. Make sure that you follow the preceding JavaScript guidelines. I ll cover some advanced JavaScript techniques in Chapter 8. Including Unsupported Elements and Attributes In some cases you may need to add invalid content to the XHTML page. Using unsupported elements isn t good practice because it ultimately limits your audience. However there might be times when you want to add Elements or attributes that existed in earlier versions of HTML Elements or attributes that are specific to one browser New elements or .

Đã 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.