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 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2002
    Location
    Burlington, VT
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Netscape redirect to old page for old broswers

    Hey everyone...

    I am writing a page for a client right now, and I want to write the page in valid XHTML 1.0. this isnt that hard and I center the main table using this clip of css:
    Code:
    
    html, body
    {
      height: 100%;
      width: 100%;
      margin: 0;
      padding: 10;
    }
    table
    {
      height: 100%;
      width: 100%;
      text-align: center;
    }
    
    well that was all fine in good and worked great (and validated) in all the new browsers (ie 5.5, mozilla 1.1, opera 6.05), but I'm at a college now and 99 percent of the computers here still have old netscape on it, so I also tested in that, and of course about 1 line of the css actually worked on netscape and it looked horrible.

    So what I want to do is use a script that will determine if it is a browser that is capable of handling css well or not, and if it's not, like netscape 4.x then redirect it to www.domain.com/old/index.html which would be a page laid out for the old browsers without using css and not validateable??

    If anyone has an easy way to do this that works i'd appreciate it, or even just the url to a good tutorial, I don't mind.

    Thanks
    "The focused mind can pierce through stone."
    - Japanese Maxim

  • #2
    Regular Coder
    Join Date
    Sep 2002
    Location
    self.location
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    <nolayer><meta http-equiv="Refresh" content="0; url=OtherWebPage.html"></nolayer>


    This'll redirect any brand of Netscape 4, and will work whether or not JS is enabled, but I should point out that the W3C considers it invalid to nest a <meta> tag in this fashion (though I still use it anyway when needed). However, considering that you'll be putting this in your XHTML page, having that page not validate might irk you.

    So you could sniff via JS instead (which should validate):

    <SCRIPT>
    <!--
    if (document.layers) self.location.replace("OtherWebPage.html");
    //-->
    </SCRIPT>

    This needs Javascript, but the advantage is that there will no longer be any trace of the original page in the browser's history - only the second page will be there (the <meta> tag doesn't achieve this - so with <meta> if the user presses the BACK button, the browser always brings them back to OtherWebPage.html, which gets boring fast).

    ...

    The above methods are fine if you want to redirect NS4 only, but you mentioned sniffing to see if a given browser handles CSS well. That's much trickier. You can more or less sniff for general CSS implementation, but a browser could conceivably pass this test, and still not be able to implement some of your declarations properly or as expected. At any rate, the code in this instance could be :

    <SCRIPT>
    <!--
    if (!document.body || (typeof document.body.style == "undefined"))
    self.location.replace("OtherWebPage.html");
    //-->
    </SCRIPT>

    This last method is not failsafe, cuz it checks for CSS implementation via a browser's DOM (which are 2 different things). Browsers which don't recognize BODY as an object (like NS4) are taken to the OtherWebPage; browsers which do understand document.body but which don't understand the "style" sub-object are also taken to the OtherWebPage. But to achieve this, we've had to make an assumption (which isn't always a justified one) about the browser's DOM.

    The reason this last snippet is a bit fuzzy is because NS4 for example doesn't understand "document.body" but it still implements styles, albeit via its own proprietary syntax. Luckily you want to exclude NS4 anyways. Personally, I'd be a bit reluctant to actually use this last example in a page, but at the moment I can't think of more failsafe way to sniff for general styles implementation.

    ...

    You can also check the current thread below for techniques on how to feed NS4 the same webpage, while feeding it different style declarations:

    http://www.codingforums.com/showthre...&threadid=7264

  • #3
    Regular Coder
    Join Date
    Sep 2002
    Location
    Burlington, VT
    Posts
    125
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey realisis! sorry about the slow response, but I got caught up in other things and forgot about my NN4 worries! Just though I'd tell you I really appreciate the thorough response and it didn't go without notice. I like the 1 line javascript a lot, that is the one that I chose to use, works like a charm.

    Thanks again,
    -Doug
    "The focused mind can pierce through stone."
    - Japanese Maxim

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    self.location
    Posts
    181
    Thanks
    0
    Thanked 0 Times in 0 Posts
    no problem, dauvm - thanks for acknowledging.


  •  

    Posting Permissions

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