untitled

(John Hannent) #1

A better solution is to automate the process. Have your page execute a little
script when the user loads the page to test which browser and which version
the user has. Then your page can make either dynamic adjustments to the
styles (described in Chapter 16), display a warning to the user, or redirect
their browser automatically to your non-CSS, or otherwise lower-grade, pages.


Such scripts are called browser sniffers. As with all scripts, they work only if
the user hasn’t disabled scripting in their browser security settings. If you
want to experiment with sniffers, start here where you’ll find additional
details and working sniffers:


http://www.webreference.com/tools/browser/

Forcing users to upgrade ..................................................................


If you want to severely discipline any wayward visitors to your site using
weak or outdated browsers, you can use what’s called a DOM (document
object model) sniffer. If they are using a browser that’s not up to your stan-
dards (in other words, if your page won’t look the way you like in their bad
browser), tell them to upgrade. You redirect them to this location:


http://www.webstandards.org/upgrade/

There they are told why they should, if possible, upgrade, and to which
browsers and versions. The site contains links to allow the user to download
browser versions that are CSS-compliant, including IE v6 (v5 for Mac users),
Netscape v7, Firefox, Galeon, Opera v7, Safari, and Konqueror.


If you want to take this approach and redirect the user, insert this script into
the section of your Web page:


<script>

<!-- //

if (!document.getElementById) {
window.location = “http://www.webstandards.org/upgrade/”
}

// -->
</script>

By using the window.location =command, you force the user’s browser to
the Internet page specified in quotation marks. The user doesn’t click a link;
the browser just automatically avoids displaying your Web page and instead
displays, in this example, the Web Standards Project’s page.


Chapter 17: Testing and Debugging 303

Free download pdf