Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Taking_Your_Talent_to_the_Web.pdf
Скачиваний:
5
Добавлен:
11.05.2015
Размер:
9.91 Mб
Скачать

194 HOW: HTML, the Building Blocks of Life Itself: Plug-ins and Tables and Frames, Oh My!

frame enables us to write links like <a href=”companypolicy.html” target =”content”>. Naming also enables us to perform JavaScript stunts, which are mainly useful for avoiding the maddening usability hazards associated with frames, such as the following.

The Frames of Hazard

Through a search engine such as Google.com, Aunt Moira finds one of our client’s content pages. Unfortunately, that’s all she finds—the naked content page, immodestly lacking its associated navigational menu frame. Aunt Moira has no idea where she is, where she can go next, who created the site, or even how to find its home page.

We always had it in for Aunt Moira, who never failed to point out when we had gained weight or burst out in pimples, but our client would like her to be able to use the site. Because we have named our frames and because the good Lord (well, actually, Netscape) gave us JavaScript, we can instruct the browser to load named frames if they are not already visible on the page.

Thus when Aunt Moira (the old biddy) blunders her way into companypolicy.html, the browser is instructed to load the missing frames. Code like this would appear on each HTML document that made up the frame, though not on the frameset document itself:

<!-- This one makes sure the left nav is loaded. --> <script LANGUAGE=”JavaScript”>

<!--

if (top == self) self.location.href = “frameset.html”; // -->

</script>

Such a script tells the browser to make sure that frameset.html has loaded. If it has not loaded—if Aunt Moira’s browser is about to show a confusing single frame no more illuminating than a single puzzle piece—the browser gathers and assembles the missing pieces before the dear old thing has a chance to notice that anything is amiss. We don’t want to get ahead of ourselves by discussing JavaScript in the HTML chapter. Suffice to say, the need to rely on such scripts points out some of the hazards of HTML <FRAMES>, and helps explain why they are on their way out.

Taking Your Talent to the Web

195

Everything we now do with frames (and more) we can do with CSS, which is standards-compliant and avoids the usability and accessibility hazards <FRAMES> engender. But to switch from <FRAMES> to CSS, we must wait for some browsers to improve their CSS support and all users to upgrade to these better browsers.

Please Frame Safely

Some old browsers do not understand frames. Neither do text and audio browsers. Nor do Palm Pilots and web-enabled telephones. To accommodate these devices and browsers, your frameset should include a <NOFRAMES> tag. Browsers that can’t read frames can read the plain HTML that you insert between opening <NOFRAMES> and closing </NOFRAMES> tags. Copy the content that appears in your frames, paste it between the <NOFRAMES> tags, and you are on your way to creating a site everyone can access, regardless of their browser’s capabilities.

Framing Your Art

Despite these hazards and hassles, frames can be quite useful to web designers. Frames allow you to present a menu bar that stays in place while content frames change. They also enable you to create layouts where, for instance, your content will always appear in the center of the screen, regardless of the visitor’s monitor size. View Marc Klein’s Creative Republic (www.creative-republic.com) to see this in action, and then view the source to see how Marc crafted his framesets.

One other maddening thing about frames is that though Netscape invented them, it never got them exactly right. When you tell the browser to make your menu bar 25 pixels tall, you may get 25 pixels in Netscape 4, but you’re just as likely to get 32 or 16. If this suggests that you’re better off avoiding frames whenever possible, we won’t argue.

In addition to tables and frames, web designers use applets and multimedia files to create designs that are frankly unimaginable in print. We will discuss those in Chapter 12, “Beyond Text/Pictures.” Don’t skip ahead, we’re watching.

196 HOW: HTML, the Building Blocks of Life Itself: Plug-ins and Tables and Frames, Oh My!

Figure 8.3

Creatively used frames keep design elements fixed in the center of the screen, whether the visitor’s monitor is large…

Figure 8.4

…or small. Designer: Marc Klein

(www.creativerepublic.com).

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]