Is there a way to detect the width of the browser scrolling bar?

Discussion in 'Javascript' started by mbasil7, Jul 1, 2005.

  1. mbasil7

    mbasil7 Guest

    Hi at all.

    Is there a way to detect with javascript the scrolling bar with of the
    browser?

    My problem is that the the following script assing to the pos
    variable the browser window size but only internet explorer substracts
    the scrolling bar with from the result.
    <script language="JavaScript" type="text/JavaScript">
    <!--
    var pos;

    if (window.innerWidth)
    {
    pos =window.innerWidth;
    }
    else if (document.documentElement &&
    document.documentElement.clientWidth)
    {
    pos= document.documentElement.clientWidth;
    }
    else if (document.body)
    {
    pos= document.body.clientWidth;
    }

    //-->
    </script>

    At least i want to ask if there is a script that return exactly the
    width of the browser's window that i have to output any text or
    graphic?

    Thanks in advance.
     
    mbasil7, Jul 1, 2005
    #1
    1. Advertising

  2. mbasil7

    RobG Guest

    mbasil7 wrote:
    > Hi at all.
    >
    > Is there a way to detect with javascript the scrolling bar with of the
    > browser?
    >
    > My problem is that the the following script assing to the pos
    > variable the browser window size but only internet explorer substracts
    > the scrolling bar with from the result.


    For a pretty thorough treatment of browser viewport issues, have a look
    at the 'viewport' link at Quirksmode:

    <URL:http://www.quirksmode.org/>

    > <script language="JavaScript" type="text/JavaScript">


    The language attribute is depreciated, remove it. Keep the required
    'type' attribute.

    > <!--


    Hiding scripts is not necessary, potentially harmful and of zero
    benefit.

    [...]

    --
    Rob
     
    RobG, Jul 1, 2005
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matt
    Replies:
    0
    Views:
    3,603
  2. John Hann
    Replies:
    0
    Views:
    6,170
    John Hann
    Aug 21, 2004
  3. Matt
    Replies:
    9
    Views:
    71,250
  4. Eswa
    Replies:
    0
    Views:
    397
  5. Matt
    Replies:
    9
    Views:
    646
    kaeli
    Aug 23, 2004
Loading...

Share This Page