|
JavaScript @ Web Programming
Programming Shed : Programmer Store & Resources |
|
|
|
JavaScript Index - JavaScript Book : Essential JavaScript for Web Professionals
by Dan Barrett, Dan Livingston, Micah Brown Paperback: 208 pages Publisher: Prentice Hall PTR ISBN: 0130130567; 1st edition (August 3, 1999) Designed to guide you through JavaScript using examples taken straight from situations that are faced every day during Web site construction. Softcover. DLC: JavaScript (Computer program language). From the Inside Flap: Introduction Welcome! This book is something we wish we had when we were first starting out with JavaScript. At that time, there were basically two types of instructional books on the market: 1200-page tomes of seemingly arcane knowledge, and books that were overly simplified and lacking in practical information. Unfortunately, there were no books that were informative and at the same time provided instruction that could be used quickly and effectively in real-world situations. This book will guide you through JavaScript using examples taken straight from situations that are faced every day during Web site construction. It starts off with simple examples and becomes quite sophisticated with the scripting toward the end of the book. With that said, let's look a little more closely at how this book is laid out and a brief summary of scripting, as well as what JavaScript can and can't do for you. How This Book Is Laid Out Chances are that at least some of you picked up this book when your boss called you into his or her office and showed you a Web site that made use of JavaScript. You were then told in no uncertain terms that it was your job to implement the same, or similar, feature on your Web site. "No problem," you respond, while saying to yourself, "I better learnJavaScript and fast!" This is often how we expand our skills: We are given a job, and if we don't know exactly how to do it, we quickly learn how. In keeping with this real-world model, this book is split into two main projects. For each of the main projects, we will be responsible for creating and/or upgrading the Web site for a fictitious company. For the first three chapters, we will revamp the homepage for Shelley Biotechnologies, a fast-growing bio-tech startup. In each chapter we have at least one project that consists of commonly used JavaScript solutions that range from easy to moderately difficult. At the end of each chapter there are more advanced exercises that you can complete on your own to expand your skills. In the second half of the book we will make some much-needed additions to Stitch Magazine's Web site. The examples will be more advanced than those found in the first project, and they will demonstrate some of the powerful things you can do using JavaScript. The exercises in the chapters are designed to give you a solid foundation in JavaScript on which you can build as you continue to use it. You will find that more often than not there is more than one way to do things in JavaScript — there really are no right or wrong ways to accomplish tasks. For all of the examples in the book you can go to the companion Web site located at phptr/essential and download the HTML and images needed to follow along with the exercises. An Introduction to JavaScript What Is JavaScript? For those of you who are new to the world of Web development and may be learning JavaScript in conjunction with HTML, a quick introduction to JavaScript may be in order. JavaScript is Netscape's built-in, cross-platform scripting language. Like HTML, it will work on all platforms. JavaScript allows you to enhance the functionality of your Web pages by embedding applications directly into your HTML. You can use JavaScript to bu ld appl cat ons that range from adding interactivity to your pages to applications that interact with databases. Although Netscape created JavaScript, it will work on most modern browsers, including Microsoft's Internet Explorer (IE). However, IE doesn't directly support JavaScript. IE has its own scripting language — JScript — that supports most of the features found in JavaScript. In the few instances in which the languages differ, those differences are pointed out and a workaround is presented. As these are the two main browsers on the market, the scripts we will be writing will focus on them. There are two methods that you can use to include JavaScript in your Web pages — client-side and server-side. Both methods share the same basic language sets. This core language defines a base set of objects and features that will work in both client-side and server-side applications. Each method also has its own extended object and feature sets. Client-Side JavaScript: How It Works Client-side JavaScript applications are scripts that are embedded directly into your HTML pages and are executed by the user's browser as it loads the page. At least 90% of all the scripts you encounter on the Web fall into this category. Therefore, this is the method that we will use throughout this book. When the user's browser calls up an HTML page with JavaScript embedded in it, the browser's JavaScript runtime engine interprets the script from the top down, executing statements as it goes. One of the advantages of using client-side scripting is that the script can detect and make use of user-initiated events, such as changes to a form or the mouse rolling over a particular graphic. The script is then able to use that information to call other parts of the script, and all of this can be done without going back to the Web server and grabbing any more information. Because our scripts are dependent on being interpreted by the user's browser, a few words on the different browsers and how they differ in handling JavaScript are in order. Browsers and Versions. As stated earlier, IE and Navigator differ slightly in the implementation of their scripting languages. As a programmer, this makes your life a little more difficult: There will be times when a solution will work differently or not at all on different browsers. Wait — it gets worse: As Netscape and Microsoft come out with newer versions of their browsers, the versions of their scripting languages are changing as well. This means that scripts written using new features may not work in an older browser. But don't get too upset — it's not as bad as it seems. All this means is that you will have to take a little extra care in writing and checking your scripts. There are many techniques that you can use to make sure your scripts will work across the board — we will be exploring these techniques and the appropriate times to use them. However, as this book has JavaScript in its title instead of JScript, we will be concentrating mainly on Netscape's scripting language. What JavaScript Can and Can't Do While the applications that you can create using JavaScript are only limited by your imagination, there are several things that you cannot do such as access or control the user's machine. For security reasons, writing to a user's computer is severely limited. You can store data on the user's machine only through the use of a cookie, and even then you are limited to a simple text file. This protects users from scripts that might harm their computers or allow unscrupulous programmers access to personal information. A security feature called the "Same Origin Policy" also restricts the access of scripts from one origin access to certain properties or files from other locations. For example, if you have a script located at yoursite/test.html and it tries to access certain properties of an HTML page located at theirsite/ test.html, the Same Origin Policy will deny your script access. The properties that the Same Origin Policy restricts are shown in Figure I-1. FIGURE I-1 Same Origin Policy restrictions These are the main restrictions that you will encounter when writing JavaScript applications. We are sure you will find yourself at times trying to use an object or property to do something that can't be done, but those limitations are less restrictions than just a matter of learning the structure of the language. As you are starting out, if you think of a possible solution that may differ from the examples in the book, give it a shot; you can often stumble upon a solution that others may not have thought of. With all that said, let's get on with the learning. From the Back Cover: With JavaScript, you can build sites that look hotter and work smarter than ever before! Now, learn JavaScript by example, from two leading Fortune 500 Web developers! You'll learn all you need to get results as you build real-world practice sites that sell products, educate visitors, offer subscriptions, and display ads. Best of all, the finished sites are on the Web—so you can reuse the code and see exactly how your pages should look and work! Write JavaScript to do all this, and much more! • Detect browsers and platforms • Create content dynamically • Create image rollovers • Enhance navigation • Provide error handling • Generate windows • Communicate between frames Rely on Essential Guides for ALL the Web Skills You Need! All these books share the same great format, and the same dynamic website. . . so once you've used one, they're all a piece of cake! • Essential CSS & DHTML for Web Professionals • Essential PERL 5 for Web Professionals • Essential Photoshop 5 for Web Professionals • Essential JavaScript for Web Professionals • With more to come! About the Author: DAN BARRETT works as a programmer and graphic artist for a successful San Francisco Bay area web design firm, working with clients that include Hewlett-Packard, Electronic Arts, Novell, and Pacific Bell. DAN LIVINGSTON's high-profile Web design clients include Apple, Pacific Bell, and Novell. His sites have won numerous awards and have been featured on CNN Prime Time. He recently founded his own user interface company, Wire Man Productions. MICAH BROWN co-owns Etail Enterprises, a Northern California Web advertising consultancy. Sites he has developed include Dr. Laura, Pacific Bell, and Ascend. Customer Reviews Good idea.. poor delivery -- beginners don't bother!, April 23, 2000 Reviewer: A reader from New Jersey I liked the start of the book. You have just been hired to improve the web site for Shelly Biotechnologies..... The book contains a series of assignments or projects you solve. I don't see how a beginner can understand any of yet. I am professional programmer looking for teaching material for a JavaScript class. If I selected this book I would have had to teach a lot of programming concepts because the authors left it all out or didn't cover it in sufficient detail. I also agree with the folks about the numerous errors. I also question the programming expertise of the authors. I saw some unneccesary consructs that grated on my programming nerves (how could they miss it? do they really know how to program?) If they meant to produce a "copy and paste" approach to JavaScript. By this I mean, copy and paste this into your HTML make the required changes for your images or objects and don't worry about understanding anything. They failed. If it was meant to teach PROGRAMMING Javascript, they failed. If it was meant to familiarize a professional programmer with Javascript, they failed here too. So what was the point? I instruct my students to first "identify your audience", these authors should have done the same! I do not recommend this book. Check out the book "Internet & World Wide Web, How to Program" by Deitel. It is my selection as a JavaScript text. This book is not on my supplemental recommendation list. Good book for those familar with programming, October 2, 2001 Reviewer: A reader from Berkeley, CA I thought this book was great. It gives a quick enough overview to keep the attention of a student or professional. This book is not going to be a reference manual, but it is good enough to teach you the basics so you can get a feel for the language, what it does, and put it on your resume. Well done book., April 9, 2001 Reviewer: Randy Iwen from Omaha NE I see that there are readers of this book that are a little upset that they were unable to use this book as a learning tool, but as a reference, this book can't be beat. As the title states, it is for Web Professionals. If you are just learning, I reccomend that you start small and work up to this book, you won't be sorry. Can I rate 0 stars ???, March 21, 2001 Reviewer: Pablo Bosch from Paris France If you want a book that awakes your worst instincts, just buy it. Hundreds of lines to explain how a while loop works and minimalist info on Javascript itself. Full of bad jokes about a bad taste "virtual boss" obsessed with adding stupid goodies to your pages. |
|
|
© 2005-2006, Programming Shed
|