Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Content Height

  • This topic is empty.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #34412
    TWG
    Participant

    I came across some Javascript that reads the browser size. I was hoping to use the code snippet to set the height of my content area. Can anyone possibly help me with this. I’m not sure how to pass the information to my CSS, if even possible.


    function BrowserSize() {
    var viewportwidth;
    var viewportheight;
    var finalheight;

    // the more standards compliant browsers (mozilla/netscape/opera/IE7) use window.innerWidth and window.innerHeight

    if (typeof window.innerWidth != 'undefined')
    {
    viewportwidth = window.innerWidth,
    viewportheight = window.innerHeight
    }

    // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document)

    else if (typeof document.documentElement != 'undefined'
    && typeof document.documentElement.clientWidth !=
    'undefined' && document.documentElement.clientWidth != 0)
    {
    viewportwidth = document.documentElement.clientWidth,
    viewportheight = document.documentElement.clientHeight
    }

    // older versions of IE

    else
    {
    viewportwidth = document.getElementsByTagName('body')[0].clientWidth,
    viewportheight = document.getElementsByTagName('body')[0].clientHeight
    }

    finalheight = viewportheight - 200;

    document.write('

    Your viewport height is '+finalheight+'

    ');
    }
    #87532
    jamygolden
    Member

    With jQuery, you could do it like this:

    var windowHeight = $(window).height();
    var $content = $("#content");

    $content.height(windowHeight);
    #87592
    jamygolden
    Member

    Chris did a tutorial based on this. It looks like you may have had a look at it, but at the same time I’m not sure :p

Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Other’ is closed to new topics and replies.