View Full Version : Explanation of purpose of this script...

01-19-2003, 09:45 AM
I have seen the following (or similar) javascript at the head of web page sources and wonder if someone can please explain exactly what it does and also, does it require an associated .js or other file to make it work effectively?

<script language='javascript'>
var isMac = (navigator.userAgent.indexOf('Mac') != -1);
var isUnix = (navigator.userAgent.indexOf('X11') != -1);
var isPC = ((!isMac) && (!isUnix));
//var isUnix = (navigator.userAgent.indexOf('X11') != -1);
var isNav2 = ((navigator.userAgent.indexOf('compatible') == -1) &&
(navigator.appVersion.charAt(0) == "2"));
var isIE = (navigator.userAgent.indexOf('IE') != -1);
var isNetscape = (navigator.userAgent.indexOf('compatible') == -1);
var isNet6 = ((navigator.userAgent.indexOf('Gecko') != -1) &&
(navigator.userAgent.indexOf('Netscape6') != -1));
if(isIE) {
var shwScr = true;
var shwClk = true;
} else {
var shwScr = false;
var shwClk = false;



01-19-2003, 10:09 AM
umm... that script works out what browser the user is browsing in and sets the variables "shwScr" and "shwClk" true if its IE and false if its anything else. i guess that somewhere else on the page javascript uses them variables to do something for IE only.

browsers such as opera often say they are differant browsers though.

01-20-2003, 10:00 PM
Thank you redhead... I was hoping it was to instruct different OS and browsers to view pages all the same way... ie, font sizes etc.

Graeme Hackston
01-20-2003, 10:10 PM
Are you using a strict DOCTYPE ?

01-20-2003, 10:23 PM
I don't think so Graeme... I'm talking about a normal html page/s. I get into so much trouble and confusion trying to get Netscape and other browsers to view pages the same as IE does... particularly font sizes and types, although I also appreciate that users' screen resolutions may be different to the 800x600 I'm creating in.


Graeme Hackston
01-20-2003, 10:36 PM
There's no helping NN4x, it's to old. You can get IE6 win, IE5+ mac, NN6 and Opera to all read the same by making your pages strict.

replace <html> with this:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">

At first you'll probably be alarmed by the results but once you clear up the CSS mess most of your x browser headaches will be gone.

Graeme Hackston
01-20-2003, 10:39 PM
Just thinking, ther are some minor coding differences as well


01-20-2003, 10:43 PM
Thanks Mate! I'll play around with that script and link. I agree with forgetting N/S4, I was mainly concerned with later versions of browsers although many are still using IE5+.

(Mods: I realise this thread is prolly now stasrting to look like it should be in another area... pls turn ya head for a few more posts! ;)


Graeme Hackston
01-20-2003, 10:52 PM
You'll still need to isolate IE5 and IE5.5 on Windows with JS but the rest are almost exactly the same. The only difference I've found is in list image bullet positioning but it could have been something I was doing.

Once you get things set up pressing Ctrl + Alt + v in Opera feeds your page into the W3C validator. It finds mistakes for you.

01-21-2003, 03:52 AM
Originally posted by Graeme Hackston
There's no helping NN4x, it's to old.

/me just a whispers® to gra...
old??? /me tends to think of it more as just a experienced® lol...

n' wonders are ya the sammme way helpin' little 'experienced' ol' ladies to cross the street tooo??? hehehe...

just a hugs® n' only teasing ya...:O)))

Graeme Hackston
01-21-2003, 10:32 PM
Yes justame

Better the poor old dear doesn't learn to cross the street for fear of her being run over :)