- •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
316 HOW: The Joy of JavaScript: Watching the Detection
WATCHING THE DETECTION
Problem: Your site absolutely requires that the user have a plug-in installed on her system (see Chapter 12 for more about plug-ins). Simply enough, use JavaScript plug-in detection (http://
www.javascriptworld.com/scripts/script02.08.html). But some browsers do not understand JavaScript plug-in detection, even though they perform many other JavaScript functions perfectly. What on earth can you do about that?
Solution: Load o’ code—JavaScript browser and platform detection code, that is.
Did someone say “complex browser and platform detection?” Oh, joy. An example of that very thing follows. Specifically, it is one of Juxt Interactive’s (see Figure 11.7) browser detection scripts of late 2000, written, in part, to compensate for the fact that Juxt uses the Flash plug-in extensively, and IE4.5/Mac (and earlier) did not recognize JavaScript’s plug-in detection method—though the browser was otherwise JavaScript-capable.
Figure 11.7
The gifted designers and programmers at Juxt Interactive rely heavily on the Macromedia Flash plug-in. Juxt must be certain its visitors have the plug-in installed before throwing heaps
of Flash content their way. JavaScript plug-in detection is the answer, but plug-in detection fails in some browsers. Juxt’s developers tackled this problem by writing the mother of all plug-in, browser, and platform detection scripts (www.juxtinteractive.com).
Taking Your Talent to the Web |
317 |
If this entire chapter so far has you seriously contemplating a career as an oil painter, we suggest you skip the next few pages, at least for now. However, we should point out that what you are about to see is not so much complex as complete.
At first glance, the river of code you’re about to drown in looks like one advanced function after another. In truth it is just a few functions, repeated over and over again so that every browser version, on every possible platform, can be recognized and accounted for.
The first code torrent that follows lives in a global JavaScript file called sniffer.js. We’ll discuss global JavaScript files in a later section, “Going Global with JavaScript,” (just as soon as we get through this section).
The second river of ‘Script lives in an HTML page called testSniffer.htm.
Let’s examine them both, shall we?
Please don’t freak. Here’s sniffer.js in all its glory:
//////////////////////////////////////////////////////
//source: juxtinteractive.com
//description: Flash 3, 4 AND 5 Detection
//Author: anthony@juxtinteractive.com
//credits: netscape communications (client sniff)
//Permission granted to reuse and distribute
//Last Modified: 10-03-00
//////////////////////////////////////////////////////
/////////////////////////////////////////
// Convert userAgent string to Lowercase
/////////////////////////////////////////
var agt=navigator.userAgent.toLowerCase();
///////////////////
// Browser Version
///////////////////
318 HOW: The Joy of JavaScript: Watching the Detection
var is_major = parseInt(navigator.appVersion); var is_minor = parseFloat(navigator.appVersion);
var is_ns = ((agt.indexOf(‘mozilla’)!=-1) && (agt.indexOf(‘spoofer’)==-1) &&(agt.indexOf(‘compatible’) == -1) && (agt.indexOf(‘opera’)==-1) &&(agt.indexOf(‘webtv’)==-1));
var is_ie = (agt.indexOf(“msie”) != -1);
////////////
// Platform
////////////
var is_win = ( (agt.indexOf(“win”)!=-1) || (agt.indexOf(“16bit”)!=-1) );
var is_win95 = ((agt.indexOf(“win95”)!=-1) || (agt.indexOf(“windows 95”)!=-1)); var is_win16 = ((agt.indexOf(“win16”)!=-1) || (agt.indexOf(“16bit”)!=-1) ||(agt.indexOf(“windows 3.1”)!=-1) || (agt.indexOf(“windows 16-bit”)!=-1) );
var is_win31 = ((agt.indexOf(“windows 3.1”)!=-1) || (agt.indexOf(“win16”)!=-1) ||(agt.indexOf(“windows 16-bit”)!=-1));
var is_win98 = ((agt.indexOf(“win98”)!=-1) || (agt.indexOf(“windows 98”)!=-1)); var is_winnt = ((agt.indexOf(“winnt”)!=-1) || (agt.indexOf(“windows nt”)!=-1));
var is_win32 = (is_win95 || is_winnt || is_win98 || ((is_major >= 4) && (navigator.platform == “Win32”)) || (agt.indexOf(“win32”)!=-1) || (agt.indexOf(“32bit”)!=-1));
var is_mac= (agt.indexOf(“mac”)!=-1);
/////////////////////////////////////
//Detect IE 4.5 on the mac
//Mucho Problemos with this browser
/////////////////////////////////////
var is_ie45mac = (is_mac && is_ie && (agt.indexOf(“msie 5.0”)==-1) &&(agt.indexOf(“msie 5.5”)==-1) && (agt.indexOf(“msie 4.5”)!=-1));
//////////////////////////////////////////
//Flash 3, 4 AND 5 Detection
//Last Modified: 10-03-00
//NOT checking for enabledPlugin (buggy)
//////////////////////////////////////////
var is_flash5 = 0; var is_flash4 = 0; var is_flash3 = 0;
if (navigator.plugins[“Shockwave Flash”]) { var plugin_version = 0;
var plugin_description = navigator.plugins[“Shockwave Flash”].description.split(“ “); for (var i = 0; i < plugin_description.length; ++i) { if (isNaN(parseInt(plugin_description[i])))
continue;
plugin_version = plugin_description[i];
}
Taking Your Talent to the Web |
319 |
}
if (plugin_version >= 5) { is_flash5 = 1;
}
if (plugin_version >= 4) { is_flash4 = 1;
}
if (plugin_version >= 3) { is_flash3 = 1;
}
if (is_ie && is_win32) { // Check IE on windows for flash 3, 4 AND 5 using VB Script document.write(‘<SCRIPT LANGUAGE=”VBScript”\>\n’);
document.write(‘on error resume next\n’);
document.write(‘is_flash5 = (IsObject(CreateObject(“ShockwaveFlash.ShockwaveFlash.5”)))\n’);
document.write(‘on error resume next\n’);
document.write(‘is_flash4 = (IsObject(CreateObject(“ShockwaveFlash.ShockwaveFlash.4”)))\n’);
document.write(‘on error resume next\n’);
document.write(‘is_flash3 = (IsObject(CreateObject(“ShockwaveFlash.ShockwaveFlash.3”)))\n’);
document.write(‘<’+’/SCRIPT> \n’);
}
And now the browser and plug-in detector, as used in the HTML document:
testSniffer.htm:
<html>
<head>
<title>testSniffer - juxtinteractive.com</title>
<meta HTTP-EQUIV=”Content-Type” CONTENT=”text/html; charset=iso-8859-1”> <SCRIPT TYPE=”text/javascript” SRC=”sniffer.js”></SCRIPT>
</head>
<BODY BGCOLOR=”#000000” TOPMARGIN=”0” LEFTMARGIN=”10” MARGINWIDTH=”10”MARGINHEIGHT=”0” LINK=”#CCCC33” VLINK=”#CCCC33” ALINK=”#FFFFFF”TEXT=”#999900”>
<br>
<font FACE=”Verdana” size=”2”>
//////////////////////////////////////////////////////<br>
//source: juxtinteractive.com<br>
//description: Flash 3, 4 AND 5 Detection<br>
//Author: anthony@juxtinteractive.com<br>
//credits: netscape communications (client sniff)<br>
//Permission granted to reuse and distribute<br>
//Last Modified: 10-03-00<br>
//////////////////////////////////////////////////////<br>
320 HOW: The Joy of JavaScript: Watching the Detection
<br>
<br>
<b>Function examples</b> <br>
(the page uses the external JS file “sniffer.js”) <br>
<br>
<br>
<script> <!--
if (is_ie45mac) {
document.write(‘It seems you are using IE 4.5 on the mac — a extremly buggy browser,you should consider upgrading to IE5 ASAP!\n’);
}
// Check Flash if (is_flash5)
{document.write(‘This browser can play FLASH 5 movies<br>\n’);
} if (is_flash4) { document.write(‘This browser can play FLASH 4 movies<br>\n’);} if(is_flash3) { document.write(‘This browser can play FLASH 3 movies<br>\n’);} else {
document.write(‘This browser CANNOT play FLASH movies<br>\n’);} //-->
</script>
<br>
<br>
</font>
</body>
</html>
Scared you, didn’t it? Scares us, too.
Don’t be alarmed. This is the province of web developers, not web designers. You would not be called upon to create JavaScript this detailed yourself. (Besides, if you ever are, you can use Juxt’s script. Note the comment:
“Permission granted to reuse and distribute,” an act of grace and kindness that is typical of the way web designers share information with their peers.)
There are things we dislike about these torrents of code besides the fact that they are torrents of code. Mainly we’re unhappy with the nonstandard, old-style “extended” HTML markup. This page would not validate. As HTML, it is not the best role model. As JavaScript, it will do ‘til the next browser upgrade comes along.