- •Taking Your Talent to the Web
- •Introduction
- •1 Splash Screen
- •Meet the Medium
- •Expanding Horizons
- •Working the Net…Without a Net
- •Smash Your Altars
- •Breath Mint? Or Candy Mint?
- •Where’s the Map?
- •Mars and Venus
- •Web Physics: Action and Interaction
- •Different Purposes, Different Methodologies
- •Web Agnosticism
- •Point #1: The Web Is Platform-Agnostic
- •Point #2: The Web Is Device-Independent
- •The 18-Month Pregnancy
- •Chocolatey Web Goodness
- •’Tis a Gift to Be Simple
- •Democracy, What a Concept
- •Instant Karma
- •The Whole World in Your Hands
- •Just Do It: The Web as Human Activity
- •The Viewer Rules
- •Multimedia: All Talking! All Dancing!
- •The Server Knows
- •It’s the Bandwidth, Stupid
- •Web Pages Have No Secrets
- •The Web Is for Everyone!
- •Swap text and code for images
- •Prune redundancy
- •Cache as Cache Can
- •Much Ado About 5K
- •Screening Room
- •Liquid Design
- •Color My Web
- •Thousands Weep
- •Gamma Gamma Hey!
- •Typography
- •The 97% Solution
- •Points of Distinction
- •Year 2000—Browsers to the Rescue
- •Touch Factor
- •Appropriate Graphic Design
- •User Knowledge
- •What Color Is Your Concept?
- •Business as (Cruel and) Usual
- •The Rise of the Interface Department
- •Form and Function
- •Copycats and Pseudo-Scientists
- •Chaos and Clarity
- •A Design Koan: Interfaces Are a Means too Often Mistaken for an End
- •Universal Body Copy and Other Fictions
- •Interface as Architecture
- •Ten (Okay, Three) Points of Light
- •Be Easily Learned
- •Remain Consistent
- •Continually Provide Feedback
- •GUI, GUI, Chewy, Chewy
- •It’s the Browser, Stupid
- •Clarity Begins at Home (Page)
- •I Think Icon, I Think Icon
- •Structural Labels: Folding the Director’s Chair
- •The Soul of Brevity
- •Hypertext or Hapless Text
- •Scrolling and Clicking Along
- •Stock Options (Providing Alternatives)
- •The So-Called Rule of Five
- •Highlights and Breadcrumbs
- •Consistent Placement
- •Brand That Sucker!
- •Why We Mentioned These Things
- •The year web standards broke, 1
- •The year web standards broke, 2
- •The year web standards broke, 3
- •The year the bubble burst
- •5 The Obligatory Glossary
- •Web Lingo
- •Extranet
- •HTML
- •Hypertext, hyperlinks, and links
- •Internet
- •Intranet
- •JavaScript, ECMAScript, CSS, XML, XHTML, DOM
- •Web page
- •Website
- •Additional terminology
- •Web developer/programmer
- •Project manager
- •Systems administrator (sysadmin) and network administrator (netadmin)
- •Web technician
- •Your Role in the Web
- •Look and feel
- •Business-to-business
- •Business-to-consumer
- •Solve Communication Problems
- •Brand identity
- •Restrictions of the Medium
- •Technology
- •Works with team members
- •Visually and emotionally engaging
- •Easy to navigate
- •Compatible with visitors’ needs
- •Accessible to a wide variety of web browsers and other devices
- •Can You Handle It?
- •What Is the Life Cycle?
- •Why Have a Method?
- •We Never Forget a Phase
- •Analysis (or “Talking to the Client”)
- •The early phase
- •Design
- •Brainstorm and problem solve
- •Translate needs into solutions
- •Sell ideas to the client
- •Identify color comps
- •Create color comps/proof of concept
- •Present color comps and proof of concept
- •Receive design approval
- •Development
- •Create all color comps
- •Communicate functionality
- •Work with templates
- •Design for easy maintenance
- •Testing
- •Deployment
- •The updating game
- •Create and provide documentation and style guides
- •Provide client training
- •Learn about your client’s methods
- •Work the Process
- •Code Wars
- •Table Talk
- •XHTML Marks the Spot
- •Minding Your <p>’s and q’s
- •Looking Ahead
- •Getting Started
- •View Source
- •A Netscape Bonus
- •The Mother of All View Source Tricks
- •Doin’ it in Netscape
- •Doin’ it in Internet Explorer
- •Absolutely Speaking, It’s All Relative
- •What Is Good Markup?
- •What Is Sensible Markup?
- •HTML as a Design Tool
- •The Frames of Hazard
- •Please Frame Safely
- •Framing Your Art
- •<META> <META> Hiney Ho!
- •Search Me
- •Take a (Re)Load Off
- •WYSIWYG, My Aunt Moira’s Left Foot
- •Code of Dishonor
- •WYS Is Not Necessarily WYG
- •Publish That Sucker!
- •HTMHell
- •9 Visual Tools
- •Photoshop Basics: An Overview
- •Comp Preparation
- •Dealing with Color Palettes
- •Exporting to Web-Friendly Formats
- •Gamma Compensation
- •Preparing Typography
- •Slicing and Dicing
- •Rollovers (Image Swapping)
- •GIF Animation
- •Create Seamless Background Patterns (Tiles)
- •Color My Web: Romancing the Cube
- •Dither Me This
- •Death of the Web-Safe Color Palette?
- •A Hex on Both Your Houses
- •Was Blind, but Now I See
- •From Theory to Practice
- •Format This: GIFs, JPEGs, and Such
- •Loves logos, typography, and long walks in the woods
- •GIFs in Photoshop
- •JPEG, the Other White Meat
- •Optimizing GIFs and JPEGs
- •Expanding on Compression
- •Make your JPEGS smaller
- •Combining sharp and blurry
- •Animated GIFs
- •Creating Animations in ImageReady
- •Typography
- •The ABCs of Web Type
- •Anti-Aliasing
- •Specifying Anti-Aliasing for Type
- •General tips
- •General Hints on Type
- •The Sans of Time
- •Space Patrol
- •Lest We Fail to Repeat Ourselves
- •Accessibility, Thy Name Is Text
- •Slicing and Dicing
- •Thinking Semantically
- •Tag Soup and Crackers
- •CSS to the Rescue…Sort of
- •Separation of Style from Content
- •CSS Advantages: Short Term
- •CSS Advantages: Long Term
- •Compatibility Problems: An Overview
- •Working with Style Sheets
- •Types of Style Sheets
- •External style sheets
- •Embedding a style sheet
- •Adding styles inline
- •Fear of Style Sheets: CSS and Layout
- •Fear of Style Sheets: CSS and Typography
- •Promise and performance
- •Font Size Challenges
- •Points of contention
- •Point of no return: browsers of the year 2000
- •Absolute size keywords
- •Relative keywords
- •Length units
- •Percentage units
- •Looking Forward
- •11 The Joy of JavaScript
- •What Is This Thing Called JavaScript?
- •The Web Before JavaScript
- •JavaScript, Yesterday and Today
- •Sounds Great, but I’m an Artist. Do I Really Have to Learn This Stuff?
- •Educating Rita About JavaScript
- •Don’t Panic!
- •JavaScript Basics for Web Designers
- •The Dreaded Text Rollover
- •The Event Handler Horizon
- •Status Quo
- •A Cautionary Note
- •Kids, Try This at Home
- •The Not-So-Fine Print
- •The Ever-Popular Image Rollover
- •A Rollover Script from Project Cool
- •Windows on the World
- •Get Your <HEAD> Together
- •Avoiding the Heartbreak of Linkitis
- •Browser Compensation
- •JavaScript to the Rescue!
- •Location, location, location
- •Watching the Detection
- •Going Global with JavaScript
- •Learning More
- •12 Beyond Text/Pictures
- •You Can Never Be Too Rich Media
- •Server-Side Stuff
- •Where were you in ‘82?
- •Indiana Jones and the template of doom
- •Serving the project
- •Doing More
- •Mini-Case Study: Waferbaby.com
- •Any Size Kid Can Play
- •Take a Walk on the Server Side
- •Are You Being Served?
- •Advantages of SSI
- •Disadvantages of SSI
- •Cookin’ with Java
- •Ghost in the Virtual Machine
- •Java Woes
- •Java Woes: The Politically Correct Version
- •Java Joys
- •Rich Media: Exploding the “Page”
- •Virtual Reality Modeling Language (VRML)
- •SVG and SMIL
- •SMIL (through your fear and sorrow)
- •Romancing the logo
- •Sounds dandy, but will it work?
- •Promises, Promises
- •Turn on, Tune in, Plug-in
- •A Hideous Breach of Reality
- •The ubiquity of plug-ins
- •The Impossible Lightness of Plug-ins
- •Plug-ins Most Likely to Succeed
- •Making It Work: Providing Options
- •The “Automagic Redirect”
- •The iron-plated sound console from Hell
- •The Trouble with Plug-ins
- •If Plug-ins Run Free
- •Parting Sermon
- •13 Never Can Say Goodbye
- •Separation Anxiety
- •A List Apart
- •Astounding Websites
- •The Babble List
- •Dreamless
- •Evolt
- •Redcricket
- •Webdesign-l
- •When All Else Fails
- •Design, Programming, Content
- •The Big Kahunas
- •Beauty and Inspiration
- •Index
294 HOW: The Joy of JavaScript: The Dreaded Text Rollover
Figure 11.1
The status bar text rollover in action at the personal site of Derek Powazek. Placing the mouse over DESIGN FOR COMMUNITY in the menu bar causes the phrase [DESIGN FOR COMMUNITY] to appear in the status bar at the bottom left of the browser. By mastering the basic text rollover, even beginners can emulate at least one Powazek design trick (www.powazek.com).
THE DREADED TEXT ROLLOVER
Problem: Your client is insane about branding. In his restaurants, he brands everything from the napkins to the silverware. He expects the same level of branding on his site.
Solution: The JavaScript text rollover lets you brand even HTML links (see Figure 11.1).
Visit a typical site, and hold your mouse cursor over a link. You usually see something like this:
http://www.fashionmaven.com/fashions/men/index.html
Not terribly interesting, not very informative for the average citizen, and it certainly won’t help your brand-happy client. How much better would it be if the visitor saw a message like this?
FASHION MAVEN fashions for men.
Taking Your Talent to the Web |
295 |
Many visitors might find this message far more useful than a bare-naked URL. And your client would certainly dig it. Fortunately, it is easy to accommodate these visitors and your client with JavaScript. Text rollovers are one of the easiest effects you can possibly create.
First, let’s look at a typical HTML link:
Explore FASHION MAVEN <a href=”/fashions/men/”>fashions for men</a>.
Notice that we’ve used an absolute link, as explained in Chapter 8, “HTML, The Building Blocks of Life Itself.” There is no need to waste bandwidth by including http:// or the company’s domain name in the link; both the http:// and the domain name are understood. There is also no need to waste bandwidth on “index.html” because the systems administrator will have configured the server to display index.html when no other document is specified. (Some systems administrators specify welcome.html or index.htm or default.htm instead, but the same rules apply. If default.htm is the default document on your server, you can link to it without typing it. But we digress.)
A visitor dragging her mouse over such a link will see the page’s URL and nothing more:
http://www.fashionmaven.com/fashions/men/index.html
Let’s give the visitor something more informative than the page’s URL.
The Event Handler Horizon
Built into JavaScript are two powerful event handlers: onMouseOver and onMouseOut. Event handlers enable you to create functions that take place during an event. In this case, the event is that the visitor is dragging her mouse cursor over a link—pretty simple stuff.
Many event handlers are built into JavaScript, but these are the two that will help us right now. Let’s take the link just listed and make it more illuminating using JavaScript’s onMouseOver event handler:
Explore FASHION MAVEN <a href=”/fashions/men/” onMouseOver =”window.status=’FASHION MAVEN fashions for men.’; return true;”>fashions for men</a>.
296 HOW: The Joy of JavaScript: The Dreaded Text Rollover
What is going on here?
We’ve used the onMouseOver event handler to tell the browser that something is supposed to happen when the visitor’s mouse hovers over this link. The event handler is followed by the equal sign in the same way that links and other standard bits of HTML use the equal sign.
As you may have guessed, window.status is JavaScript’s charming way of referring to the status bar at the bottom of the web page. (The status bar is the part of the browser that usually displays the bare-naked URL, generally at the lower left.) Without getting too hairy, JavaScript gives each object in its document model an address based on the object’s position within the document’s hierarchy, moving from the top level of the hierarchy down to the details: window is a top-level object; status is the object being modified via JavaScript. (Like we said, buy the JavaScript books if you want a better explanation, and you probably do.)
Notice that the status bar message text ‘FASHION MAVEN fashions for men.’ is enclosed within single quotation marks. This is because the JavaScript itself is enclosed within double quotation marks. If the text also used double quotation marks, the browser would not know how to distinguish the quoted JavaScript from the quoted text.
Observe also that both the description and the phrase return true end in a semicolon. This is basic JavaScript syntax, so get used to it. There are more semicolons in JavaScript than in all Charles Dickens’s novels combined. Technically, the semicolon is not required when a JavaScript statement ends the line. So,
window.status = “some thing”
is perfectly valid JavaScript in the context of a function, a la:
<script type=”text/javascript”> function rollover() {
window.status = “some thing” // no semicolon
}
</script>
But if you are placing two or more statements on a single line, as you would inside an event handler attribute, you must separate the statements by semicolons.
Taking Your Talent to the Web |
297 |
Finally, note that return true is used at the end to handle the event. It tells the browser to follow the HTML link. Return false would tell the browser not to follow the link, which can be useful when you don’t want to load a new page.
Status Quo
So far, so good—now let’s make our little example even more exciting. (Well, as exciting as this kind of stuff gets.) Let’s craft a message that shows up in the status bar when the visitor stops hovering over the link:
Explore FASHION MAVEN <a href=”/fashions/men/” onMouseOver =”window.status=’FASHION MAVEN fashions for men.’; return true;” onMouseOut=”windowstatus=’Welcome to FASHION MAVEN.’; return true;”>fashions for men</a>.
What have we done? (Besides further prostituting ourselves to FASHION
MAVEN, that is.)
We’ve used exactly the same syntax to replace the onMouseOver message with a default status bar message. When the user places the mouse pointer over the link, he’ll read “FASHION MAVEN fashions for men.” When he releases the mouse, our insistent client will replace that link-specific brand message with a general one: “Welcome to FASHION MAVEN.” This general message will remain in the visitor’s status bar until he moves the mouse over a new link. If we had not done this, “FASHION MAVEN fashions for men” would have been “stuck” in the status bar window even after the visitor removed his mouse from that link.
None of what we’ve just shown you requires any custom scripting or preparation in the <HEAD> of the HTML document. The onMouseOver and onMouseOut event handlers are as old as the hills, and any JavaScriptcapable browser will handle this code natively. (As we’ll see later, other JavaScript techniques require a script before the function itself.)
Well, this is fine for a single link, but coding identical onMouseOut messages for a dozen links seems like a lot of work, doesn’t it? There ought to be a shortcut! And fortunately, there is. (Programmers are always creating shortcuts.)
298 HOW: The Joy of JavaScript: The Dreaded Text Rollover
In the <BODY> tag of our HTML document, we can add this line of code:
<body onLoad=”window.defaultStatus=’Welcome to FASHION MAVEN.’”>
For the sake of simplicity, we’ve left out the rest of the markup you might normally include in the <BODY> tag, such as the default background color, text color, and so on. Of course, if you’re following W3C recommendations and using CSS to handle your site’s stylistic elements, then your <BODY> tag can be as simple as <BODY> with no extra junk inside it.
As you have probably deduced, onLoad is another event handler. In this case, the event is the loading of the web page itself. When the page loads (the event), a function must be performed. In this case, you’ve instructed the browser that the required function is a change in the status bar message. Thanks to your cleverness, even before the visitor hovers over a link, the status bar at the bottom of the browser will proudly proclaim, “Welcome to FASHION MAVEN.” Can you feel your client’s love? We can. You have now carried your client’s brand down to the level of the status bar. Had you not done this, the status bar would read “Internet Zone” or something equally meaningless (as far as your client is concerned).
But wait, there’s more! Because the onLoad event handler in our <BODY> tag is telling the browser to proclaim “Welcome to FASHION MAVEN.” by default, we can simplify our JavaScript link as follows:
Explore FASHION MAVEN <a href=”/fashions/men/” onMouseOver =”window.status=’FASHION MAVEN fashions for men.’; return true;” onMouseOut=”window status=’’;return true;”>fashions for men</a>.
What changed? Look closely. We’ve removed the redundant text “Welcome to FASHION MAVEN” and replaced it with Folger’s Crystals. Just kidding. Actually, we’ve replaced it with an empty pair of single quotations, which tell the browser to revert to the default text specified by the onLoad event handler (“Welcome to FASHION MAVEN”), We no longer have to type “Welcome to FASHION MAVEN.” in the JavaScript text link itself.
That may not seem like much of an achievement. That’s because it’s not much of an achievement. But if there are a dozen links on this page, all requiring JavaScript text messages, we’ve saved ourselves the trouble of typing the same onMouseOut text 12 times. We’ve also saved the viewer the trouble of downloading those few kilobytes of redundant text.