Advanced Search

Results 1 to 2 of 2

Thread: Small little redirect problem..

  1. #1
    Join Date
    Jun 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Small little redirect problem..

    I've never built Javascript before :P So bear with me. It's only recently that I learned the barebones of C++, so this stuff looks a little more understandable to me. I figured I'd tinker around a bit.

    Looking at the script I made, you can understand what I want it to do. But it's just.. not. working. T__T And I don't see where I went wrong, which is probably the problem, lol.

    So anyway, here it is..

    <script language="Javascript">

    if (screen.width == 1024) && (navigator.appName == "Microsoft Internet Explorer") {
    document.location = "[link]";
    }
    else if (screen.width == 1024) && !(navigator.appName == "Microsoft Internet Explorer"){
    window.location = "[link]";
    }
    else if !(screen.width == 1024) && (navigator.appName == "Microsoft Internet Explorer"){
    window.location = "[link]";
    }
    else if !(screen.width == 1024) && !(navigator.appName == "Microsoft Internet Explorer"){
    window.location = "[link]";

    </script>

    If anyone could point me in the right direction, that would be great =) Thank you!

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by hhp5
    Looking at the script I made, you can understand what I want it to do.
    You're trying to redirect based upon apparent browser vendor and reported viewport dimensions. Don't. Neither information is relevant to the business of Web development, and don't really tell you anything useful.

    Monitor dimensions are pointless because they don't tell you what the viewport size is. That is, the space in which a document is rendered. Just because I might have a display size of 1600x1200 doesn't mean that all of it is dedicated to the browser. In fact, the larger the monitor, the less that should be true.

    The navigator object only reports what the user wants it to report. Quite perversely, Microsoft started the whole business of browser spoofing, and ever since made the ability to reliably determine the browser in use impossible.

    If you're having problems with browsers rendering your site differently - the usual reason for doing what you're attempting - then fix the site. Trying to maintain different versions is a waste of effort, and only covers a limited number of cases. You shouldn't be designing a document for any browser in particular; as long as you do things properly, every browser is capable of rendering a document well.

    I'll note right here that pixel-perfect design is a futile goal. It just isn't possible. Moreover, why bother? Who's actually going to compare two browsers? The only realistic goal is to make a document render well (which in the majority of cases reads as 'similar').

    Mike

Bookmarks

Posting Permissions

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