This works in IE6, but not FF2 or Opera9

Discussion in 'Javascript' started by Zilbandy, Nov 20, 2006.

  1. Zilbandy

    Zilbandy Guest

    I've tried the following with IE6, FireFox2 and Opera9. Javascript is
    enabled in all three browsers but this only works in IE. I'm very new
    to Javascript and this first exercise is very frustrating. Here's the
    code in question:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE>Tubac Woodworks, Inc. — Portfolio</TITLE>
    <META http-equiv="Content-Type" Content="text/html; charset=utf-8">
    <META http-equiv="refresh" content="2;url=./PageB/frameset.htm">
    <script type="text/javascript" language="javascript">
    function detect(){
    if(screen.width<1024){
    location.href('PageA/frameset.htm');
    }else{
    location.href('PageB/frameset.htm');
    }
    }
    </script>
    </HEAD>
    <BODY onLoad="detect()">
    </BODY>
    </HTML>

    The url to the page of concern is http://tubacwoodworks.com. If you
    visit this page, no comments on using frames for layout, please. I'm
    trying to address one problem at a time. :) CSS is just as new to me
    as JS.
     
    Zilbandy, Nov 20, 2006
    #1
    1. Advertisements

  2. Zilbandy

    Randy Webb Guest

    Zilbandy said the following on 11/20/2006 12:47 AM:
    Drop the language attribute, it is deprecated.
    Check the JS Console and it will tell you "location.href is not a
    function". You don't call it the way you did, you set it:

    location.href="PageA/frameset.htm";
    Same here.

    A better question to ask yourself is why does my resolution matter? What
    is more important is the size of the browser window and you can find
    code here:

    <URL: http://jibbering.com/faq/#FAQ4_9>

    <FAQENTRY>
    4.9 needs to be renamed, it doesn't deal with the size of the window. It
    should also have a note added specifying that you can't get the proper
    dimensions until after the page has finished loading

    Between the last code box and the links:

    Note: The dimensions can not be determined accurately until after the
    document has finished loading.

    </FAQENTRY>
     
    Randy Webb, Nov 20, 2006
    #2
    1. Advertisements

  3. Zilbandy

    Zilbandy Guest

    Thank you. That seems to have fixed it. :)

    I load smaller images for those using 800x600 screen resolution to
    avoid horizontal scroll bars. Let's face it, if you are still using
    800x600, you are probably running full screen, or you surely have a
    fetish for horizontal scroll bars with the seemingly vast majority of
    sites today needing 1024x768 run at full screen to avoid horizontal
    scrolling. And, then there are the ones that even when using 1024x768
    seem to be a few pixels too big anyway and still have scroll bars.
    It's like the "designer" forgot about the window borders and the
    vertical scroll bars when they built the page. :)
     
    Zilbandy, Nov 20, 2006
    #3
  4. Zilbandy

    ASM Guest

    Zilbandy a écrit :
    it is a very bad idea :
    my screen is >1024 width
    but my borowser's window is by 850px width ...
    location.href = 'PageA/frameset.htm';
     
    ASM, Nov 20, 2006
    #4
  5. Zilbandy

    ASM Guest

    Zilbandy a écrit :
    But my screen is 1152/870
    Does that mean I use my browsers in full screen ? Not at all !
    It's why I visit them in 850 width
    --> avoid right column with advertisements ;-)
    You know you can code in proportional sizing ?
    (all the page adapts its elements relatively to free space in width)
     
    ASM, Nov 20, 2006
    #5
  6. Zilbandy

    Zilbandy Guest


    Then that means you should have no problems viewing my site with no
    horizontal scrolling needed. :)
     
    Zilbandy, Nov 20, 2006
    #6
  7. Zilbandy

    Zilbandy Guest

    Then you would notice the note on the page to select the smaller page
    if images appeared too big. Still, not a problem. I'd venture a guess
    that your "typical" internet user is using either 800x600 or 1024x768
    at full screen. By virtue of the fact that you are answering questions
    in this group tells me you are not the "typical" user. To you, it's a
    "very bad" idea; to me, it seems like a decent solution.
     
    Zilbandy, Nov 20, 2006
    #7
  8. Zilbandy

    Randy Webb Guest

    Zilbandy said the following on 11/20/2006 12:45 PM:
    I would beg to differ with that statement. The "typical" internet user
    doesn't use full screen. The IT department where I work had a big
    argument about two years ago about whether people surfed in max mode or
    not (maximized or full scree - they are distinct). The solution? We put
    a JS snippet in the homepage that logs the screen width and the browser
    width to the server. Results? 99% did *not* surf maximized or full
    screen. The average seems to be about 50-60% of desktop width. Stats are
    flawed by the very nature of them but I don't think the "typical user"
    surfs the web with the browser maximized.
     
    Randy Webb, Nov 20, 2006
    #8
  9. Zilbandy

    Zilbandy Guest

    I find that hard to believe, based on just visiting random web sites.
    If that's the case, there's an awfully lot of people accepting the use
    of horizontal scrolling. I am forced to use 800x600 if I want to be
    able to read the text and the vast majority of pages are not
    "friendly" at this resolution. I just can't imagine making the screen
    more narrow yet. I guess the point is that you can't please everybody.
    I got my Javascript question answered, and whether or whether not what
    I'm doing with it is politically correct, I'm happy with it and my
    friend at the company I'm doing it for is happy with it... for now. :)
     
    Zilbandy, Nov 20, 2006
    #9
  10. Zilbandy

    ASM Guest

    Zilbandy a écrit :
    I think most of Windows family users have their applications opened in
    full screen (it's a default feature of Windows).
    Probably at work and usually the surf run in back in a reduced window.
    It is not "because" it is usually wrong made you have to follow them.
    No, and these ones aren't often visited (if known).
    Anyway what we mean is you have to detect available space of browser's
    window and not size of screen if you want to be compatible with any use
    of your visitors.

    Il n'y a pas à sortir de là.
     
    ASM, Nov 21, 2006
    #10
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.