Re: Resolution Sniffer?

by Thomas James Allen <tjallen(at)pipeline.com>

 Date:  Fri, 10 Sep 1999 00:13:25 -0400
 To:  NaKsanders(at)aol.com
 Cc:  hwg-basics(at)hwg.org
  todo: View Thread, Original
At 06:31 PM 9/9/99 EDT, you wrote:
>With all the talk lately about designing for different screen resolutions, I 
>was wondering if there would be a way (maybe using a javascript?) to sniff 
>out a users browser size, to direct to different pages or ideally to use 
>different style sheet settings or something...  Any ideas?
>
>-Noah
--------------------------

Noah,
Despite my partial agreement with Ted's rant, I'll admit I am doing
something like what you're asking, and I'll explain how.

Here's what you do. Design the index page for the 640x480 people,
but put in this script, and those with a higher screen resolution
are sniffed and sent to a second index page.

<script language="JavaScript">
<!-- hide js
var frHeit = 0;
if (parseInt(navigator.appVersion) >= 4) {
        frHeit = (screen.availHeight);
        if (frHeit > 500) {
        location.replace("index2.html");
        }
}
// end hide -->
</script>

Here's what's happening above: Since the sniff for screen resolution
only works on the 4+ browsers, I first sniff for that. If it's less than 4,
nothing happens. If >=4, I store their screen.availHeight in the variable
frHeit. If frHeit is >500, I send them to index2.html.

Notes: 
1. Put this script immediately after the head section, before any html
body or frameset commands.

2. The screen.availHeight does NOT tell you if their browser is maximized
or mediumized, it only tells the WHOLE desktop screen's resolution.

3. I stored their screen.availHeight in a variable in case later I wanted
to test for >650, and send those with the biggest screens to an even
bigger page. But so far, I haven't done this overkill.

4. Summary - If they have a 3.9 browser or less, or a screen height
less than 500, they don't get sent anywhere, and the page they arrived
on is the one designed for them. If they have a 4.x + browser AND
a screen height greater than 500, they get index2, a cooler page
designed for those with (potentially) more space.

Hope this helps,
jimmy
---
Jimmy Allen (Thomas James Allen)
Business - Get Your Website Here
http://www.getyourwebsitehere.com
Personal - Eclecticity
http://www.getyourwebsitehere.com/personal

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA