Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 11 of 11
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adelaide, South Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    United Kingdom Confused: Often
    Posts
    859
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adelaide, South Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Are you using a strict DOCTYPE ?

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adelaide, South Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #7
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Just thinking, ther are some minor coding differences as well

    http://www.w3schools.com/xhtml/default.asp

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Adelaide, South Australia
    Posts
    150
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #9
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #10
    Regular Coder
    Join Date
    Jun 2002
    Posts
    676
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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)))

  • #11
    Regular Coder
    Join Date
    Jun 2002
    Posts
    624
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes justame

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •