Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-19-2003, 09:45 AM   PM User | #1
^KoalaBear^
Regular Coder

 
Join Date: Jun 2002
Location: Adelaide, South Australia
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
^KoalaBear^ is an unknown quantity at this point
Explanation of purpose of this script...

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?

Code:
<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;
	}
//-->

 //-->
 </script>
Cheers!
KB...
__________________
To escape criticism - do nothing, say nothing, be nothing. . . Vaya Con Dios
^KoalaBear^ is offline   Reply With Quote
Old 01-19-2003, 10:09 AM   PM User | #2
redhead
Regular Coder

 
Join Date: Jun 2002
Location: United Kingdom Confused: Often
Posts: 859
Thanks: 0
Thanked 0 Times in 0 Posts
redhead is an unknown quantity at this point
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.
__________________
redhead
redhead is offline   Reply With Quote
Old 01-20-2003, 10:00 PM   PM User | #3
^KoalaBear^
Regular Coder

 
Join Date: Jun 2002
Location: Adelaide, South Australia
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
^KoalaBear^ is an unknown quantity at this point
Smile attn redhead

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.
__________________
To escape criticism - do nothing, say nothing, be nothing. . . Vaya Con Dios
^KoalaBear^ is offline   Reply With Quote
Old 01-20-2003, 10:10 PM   PM User | #4
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Are you using a strict DOCTYPE ?
Graeme Hackston is offline   Reply With Quote
Old 01-20-2003, 10:23 PM   PM User | #5
^KoalaBear^
Regular Coder

 
Join Date: Jun 2002
Location: Adelaide, South Australia
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
^KoalaBear^ is an unknown quantity at this point
Smile

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.

KB...
__________________
To escape criticism - do nothing, say nothing, be nothing. . . Vaya Con Dios
^KoalaBear^ is offline   Reply With Quote
Old 01-20-2003, 10:36 PM   PM User | #6
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
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:

Code:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<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 is offline   Reply With Quote
Old 01-20-2003, 10:39 PM   PM User | #7
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Just thinking, ther are some minor coding differences as well

http://www.w3schools.com/xhtml/default.asp
Graeme Hackston is offline   Reply With Quote
Old 01-20-2003, 10:43 PM   PM User | #8
^KoalaBear^
Regular Coder

 
Join Date: Jun 2002
Location: Adelaide, South Australia
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
^KoalaBear^ is an unknown quantity at this point
Thumbs up

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!

KB...
__________________
To escape criticism - do nothing, say nothing, be nothing. . . Vaya Con Dios
^KoalaBear^ is offline   Reply With Quote
Old 01-20-2003, 10:52 PM   PM User | #9
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
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.
Graeme Hackston is offline   Reply With Quote
Old 01-21-2003, 03:52 AM   PM User | #10
justame
Regular Coder

 
Join Date: Jun 2002
Posts: 676
Thanks: 1
Thanked 0 Times in 0 Posts
justame is on a distinguished road
Quote:
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)))
justame is offline   Reply With Quote
Old 01-21-2003, 10:32 PM   PM User | #11
Graeme Hackston
Regular Coder

 
Join Date: Jun 2002
Posts: 624
Thanks: 0
Thanked 0 Times in 0 Posts
Graeme Hackston is an unknown quantity at this point
Yes justame

Better the poor old dear doesn't learn to cross the street for fear of her being run over
Graeme Hackston is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:27 AM.


Advertisement
Log in to turn off these ads.