Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 429 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
429
Dung lượng
11,31 MB
Nội dung
[...]... much simpler syntax: JavaScript code here < /script> ■ You can put your JavaScript code in a separate file, then link to that file from as many HTML documents as you like: < /script> ⋮ script. js (excerpt) JavaScript code here Guess which method you should use Writing JavaScript that enhances... is a JavaScript book, after all, so let’s talk about the JavaScript that goes into your pages JavaScript for Behavior As with CSS, you can add JavaScript to your web pages in a number of ways: ■ You can embed JavaScript code directly in your HTML content: ■ You can include JavaScript code at the top of your HTML document in a tag: < /script> ⋮ 10 Simply JavaScript CDATA? If you’re wondering what all that gobbledygook is following the tag and preceding the < /script> tag, that’s what it takes to legitimately embed JavaScript in an XHTML document without confusing web browsers... Layers of the Web A big part of learning JavaScript is learning when it’s the right tool for the job, and when ordinary HTML and CSS can offer a better solution Before we dive into learning JavaScript, we’ll take a little time to review how to build web sites with HTML and CSS, and see just how JavaScript fits into the picture Chapter 2: Programming with JavaScript JavaScript is a programming language To... http://www.sitepoint.com/books/javascript1/errata.php Simply JavaScript xxi The SitePoint Forums If you’d like to communicate with other web developers about this book, you should join SitePoint’s online community.3 The JavaScript forum,4 in particular, offers an abundance of information above and beyond the solutions in this book, and a lot of fun and experienced JavaScript developers hang out there... http://www.sitepoint.com/books/html1/ Simply JavaScript xix chapter—statements, variables, expressions, loops, functions, and objects—are the building blocks for every JavaScript program you’ll ever write Chapter 3: Document Access While certain people enjoy writing JavaScript code for its own sake, you wouldn’t want to run into them in a dark alley at night As a well-adjusted web developer, you’ll probably want to use JavaScript... have JavaScript disabled in their browsers, and without interfering with other JavaScript code that might be applied to the same page, is called unobtrusive scripting Unfortunately, while many professional web developers have clued in to the benefits of keeping their CSS code in separate files, there is still a lot of JavaScript code mixed into HTML out there By showing you the right way to use JavaScript... 4 We’ll show you an example of this in Chapter 7 12 Simply JavaScript becoming an important part of the JavaScript landscape, we’ll also look at how the popular JavaScript libraries do things whenever the opportunity presents itself Here are the libraries that we’ll use in this book: Prototype http://www.prototypejs.org/ script. aculo.us http:/ /script. aculo.us/ Yahoo! User Interface Library (YUI) http://developer.yahoo.com/yui/... completely mess things up As an example, if you really, really like JavaScript, you could go so far as to put everything—content, presentation, and behavior—into your JavaScript code I’ve actually seen this done, and it’s not pretty—especially when a browser with JavaScript disabled comes along Even more telling is the fact that JavaScript is the only one of these three languages that has the ability... put it into this book for both those reasons Chapter 9: Looking Forward JavaScript doesn’t just have a future; JavaScript is the future! Okay, you might think that’s taking it a bit far, but when you read this chapter and see the many amazing things that JavaScript makes possible, you might reconsider Appendix A: The Core JavaScript Library As we progress through the book, we’ll write code to solve .