13.02.2013 Views

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

WEB STANDARDS CREATIVITY

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

188<br />

3. Bring up the Print dialog box in the browser, as shown in Figure 8-2. Unfortunately, it’s not possible to avoid this step<br />

and get it to go straight to print. The user will still have one more button to click. In the Firefox example in Figure 8-2,<br />

it’s the OK button.<br />

Figure 8-2. The Print dialog box appears before printing.<br />

4. When the visual elements for each section are created and their associated behaviors are defined, they then get<br />

inserted into the page.<br />

All of these steps should happen very quickly. Unless the web page is very long or there is an element on the web page that<br />

takes a lot longer to download than others (for example, an image from an external website that is running, like a dog, and<br />

not a greyhound at that), the user should not notice a jarring change in the page’s appearance.<br />

The reason why a single slow-loading element on a page can delay this effect is because the JavaScript runs<br />

after the page has loaded. This is because the onload event happens once everything on the page has been<br />

downloaded—all images, scripts, and CSS files linked to—rather than just the page’s markup.<br />

So, that’s the plan of attack with the dummy page. Let’s look at some of the real code that’s going to help us achieve this.<br />

Event planning<br />

The first thing that needs doing is setting up the page load events. Now there are many different ways of doing this, and just<br />

as many opinions about which method is the best (see http://tinyurl.com/ct2vy). My bet is that many of the readers of<br />

this book are at a level where they are quite capable of making up their own mind and can adapt the suggested addEvent<br />

function that I’m using (from Scott Andrew: http://tinyurl.com/qcmrd). However, even if this is not the case, and you, dear<br />

reader, have no idea what I’m talking about, fear not—it really is worrying too much about the smallest of details. Move<br />

along, nothing to see here, nothing to see . . .

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!