Product Details
JavaScript & DHTML Cookbook

JavaScript & DHTML Cookbook
By Danny Goodman

List Price: £34.50
Price: £18.66 & eligible for FREE Super Saver Delivery. Details

Availability: Usually dispatched within 24 hours
Dispatched from and sold by Amazon.co.uk

29 new or used available from £18.12

Average customer review:

Product Description

In today's Web 2.0 world, JavaScript and Dynamic HTML are at the center of the hot new approach to designing highly interactive pages on the client side. With this environment in mind, the new edition of this book offers bite-sized solutions to very specific scripting problems that web developers commonly face. Each recipe includes a focused piece of code that you can insert right into your application. Why is "JavaScript & DHTML Cookbook" so popular? After reading thousands of forum threads over the years, author and scripting pioneer Danny Goodman has compiled a list of problems that frequently vex scripters of various experience levels. For every problem he addresses, Goodman not only offers code, but a discussion of how and why the solution works.Recipes range from simple tasks, such as manipulating strings and validating dates in JavaScript, to entire libraries that demonstrate complex tasks, such as cross-browser positioning of HTML elements, sorting tables, and implementing Ajax features on the client. Ideal for novices as well as experienced scripters, this book contains more than 150 recipes for: working with interactive forms and style sheets; presenting user-friendly page navigation; creating dynamic content via Document Object Model scripting; producing visual effects for stationary content; positioning HTML elements; and working with XML data in the browser.Recipes in this Cookbook are compatible with the latest W3C standards and browsers, including Internet Explorer 7, Firefox 2, Safari, and Opera 9. Several new recipes provide client-side Ajax solutions, and many recipes from the previous edition have been revised to help you build extensible user interfaces for Web 2.0 applications. If you want to write your own scripts and understand how they work, rather than rely on a commercial web development framework, the "JavaScript & DHTML Cookbook" is a must.


Product Details

  • Amazon Sales Rank: #76582 in Books
  • Published on: 2007-08-08
  • Original language: English
  • Number of items: 1
  • Binding: Paperback
  • 604 pages

Editorial Reviews

About the Author
Danny Goodman has been writing about personal computers and consumer electronics since the late 1970s. A freelance writer and programmer, he's published hundreds of magazine articles, several commercial software products, and three dozen computer books. His most popular book titles -- on HyperCard, AppleScript, JavaScript, and Dynamic HTML -- have covered programming environments that are both accessible to non-professionals yet powerful enough to engage experts. His "JavaScript Bible" (Wiley) book is now in its fifth edition. Danny is also a programming consultant to some of the industry's top intranet development groups and corporations.

Excerpted from JavaScript and DHTML Cookbook by Danny Goodman. Copyright © 2003. Reprinted by permission. All rights reserved.
Chapter 10 - Page Navigation Techniques

10.0 Introduction
No web page is (or should be) an island. Just as there is a way to reach the page, so should there be one or more ways to navigate to other destinations, either within the same site or outside. The HTML hyperlink element—embedded in pages as the rather nondescript tag—is the conventional, nonscripted way to provide a clickable avenue for the user to navigate to another page. But more sophisticated user interface designs frequently require Dynamic HTML to assist with the presentation of navigation options and the very act of navigating.

The location Object
Each window (and frame) object in every scriptable browser has a location object whose properties contain information about the URL of the page currently loaded into the browser. This is an abstract object, meaning that the object has no particular physical presence visible on the page—except perhaps the URL that appears in the browser’s Location or Address field. But the location object does not control what the user sees in the Location/Address field unless the browser succeeds in navigating to a page you assign to the location object.

Properties of the location object are read/write. The individual properties reveal components of the URL (and even the entire URL) of the loaded page. Without any restrictions to this information, however, scripts could spy on your browser activity without you knowing it. For example, imagine entering an unscrupulous web site that looks like the Google search page. In fact, you could be viewing the actual Google search page within a frameset whose second frame is hidden from view. A script in the framesetting document or the other frame could inspect the location object of the visible frame every ten seconds, accumulating a record of every page visited in that frame. The information could then be sent back to the spoofer’s server without the user’s knowledge or permission. Despite the fact that, in some situations, knowing the URL of another frame or window could enhance the user experience, the potential for invasion of privacy has forced browser makers to clamp down on the reading power of location object properties.

Browsers observe various types of security policies to help protect a user’s privacy. The policy that applies to the location object is known as the same origin policy. If a script running in a page served by one server and domain wishes to inspect the location object of another frame or window, the document in the other frame or window must also be served by the same server and domain. If the user navigates in one of the frames to another domain or server, the same origin policy fails (even though the frameset is still served within policy), and the location information is not accessible to the other frame.

Partially as a result of a variety of security holes in Internet Explorer for Windows, Microsoft occasionally clamps down so tightly on a potential threat that attempts to read location object properties of another window or frame—even from the same origin—result in a security-related script error (such as "Access denied."). From a reliability standpoint, reading the location object is best done in the same page as the script doing the reading. As you’ll see in a few recipes in this chapter, there are some good reasons to do this.

All this security stuff, however, applies only to reading the location object’s property values. You can assign new values to the properties across window and frame boundaries with impunity.

Passing Data Between Pages
A very common model in the web-application world is essentially a forms-based navigation system, in which virtually every page is a form whose values are submitted as a way to progress to the next page. When the submitted form reaches the server, programming on the server dissects the form controls’ name/value pairs. Some of the pairs may get shunted off to a backend database. Other bits may be reformulated as values of hidden input elements in the page that gets assembled for return as the next page. Once the second page is served up, the server doesn’t know whether the user is still connected to the site or has perhaps navigated off somewhere else. In other words, the server simply reacts to requests from a browser, returning a page in response.

The server may be programmed to keep some temporary information about the user on hand, identified by a session ID. That session ID is passed down to the browser with each returned page so that when the next request arrives, the server program can tie together requests that come from a single browser. Some server programs that assemble pages on the fly for each visitor (such as amazon.com) populate the href attributes of all intrasite links with the session ID so that the server can keep passing the ID along from page to page. It may sound a bit crude, but it is much more bandwidth-efficient than maintaining a full-time connection between server and browser (or between thousands of browsers at any instant for a popular public site).However, not everyone has the requisite programming skills or server access to accomplish this server-based way of passing along live information from one page to another. By the same token, security restrictions in browsers prevent the random reading and writing of data to the local hard drive of users. Fortunately, with the help of JavaScript and various pieces of the object models, you do have a few different ways to get information from one page to another without having to involve the server. Recipes 10.4 through 10.6 show these approaches using cookies, frames, and URLs. For example, consider the case in which a user has bookmarked just one content page from a frameset whose other frames provide vital site navigation tools.


Customer Reviews

Just the job5
I have been working on developing a web application now for about 6 months and just recently got this book. I only wish I had got hold of it 6 months ago. Looking through the table of contents it contains examples of nearly all the Javascript functionality that I have struggled to incorporate into our application. I would have saved loads of time and probably have coded things a lot more efficiently if I'd had this book first. Topics such as date validation, handling script errors, creating a new window, bringing a window to the front, changing the contents of one frame from another, resizing frames, setting frameset specifications dynamically, blocking submissions from the Enter Key, Advancing Text Field Focus with the Enter Key to name just a few! I've already used it since getting it to look up modal windows and creating tree-view structures.

This is everything I expected that book to be.

I heartily recommend this book. It has tons of highly usable examples.

Excellent Book if you need to learn Javascript quickly5
I don't normally write reviews but after reading this book I felt I had to spread the good word. The style and pace of this book is excellent if you are already a programmer and need to pick up javascript quickly. You'll need a more comprehensive Javascript book to ensure you cover all bases, but if you want to learn the basics and how to actually deliver results without having to wade through chapters of general theory of programming then this is the type of book for you.

All round package5
This book delivers a lot.

It is uniquely difficult to get into client scripting because it draws on so many technologies; has been a battle ground for browser developers; and the development tools are so poor.

I read(tried to read) loads of books on client side scripting but could not get the picture I needed to understand what is going on. They either each describe a single technology which is not, in itself, enough to get started with, or they describe such a big picture that there is no practical application for the knowledge.

This book covers sufficient ground that a complete picture emerges but also links that picture to the practical details needed to get stuck in.

As well as getting me going there was plenty of depth to and detail whenever I wanted it.

I have always found that in each area there is one book which has provided the breakthrough. For client side scripting this has been that book.