scrollTo only if horizontal scrollbar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • anna

    #1

    scrollTo only if horizontal scrollbar

    How to tell if a horizontal scrollbar is present? I only want to use
    scrollTo if horizontal scrollbar is present.

    window.scrollba rs.visibility doesn't specify which scrollbar is
    present, so it gives a false result if there is vertical scrollbar but
    not horizontal scrollbar.

    TIA,
    Anna
  • mscir

    #2
    Re: scrollTo only if horizontal scrollbar

    anna wrote:[color=blue]
    > How to tell if a horizontal scrollbar is present? I only want to use
    > scrollTo if horizontal scrollbar is present.
    > window.scrollba rs.visibility doesn't specify which scrollbar is
    > present, so it gives a false result if there is vertical scrollbar but
    > not horizontal scrollbar.
    > TIA,
    > Anna[/color]

    You could give this a try, check for scrollWidth > clientWidth.
    It works for my IE6, Netscape 7.1, Firefox 0.8.

    function showscrollfeatu res() {
    var msg = 'clientHeight ' + window.document .body.clientHei ght + '\n';
    msg += 'clientWidth ' + window.document .body.clientWid th + '\n';
    msg += 'offsetHeight ' + window.document .body.offsetHei ght + '\n';
    msg += 'offsetWidth ' + window.document .body.offsetWid th + '\n';
    msg += 'scrollHeight ' + window.document .body.scrollHei ght + '\n';
    msg += 'scrollWidth ' + window.document .body.scrollWid th + '\n';
    msg += 'scrollLeft ' + window.document .body.scrollLef t + '\n';
    msg += 'scrollTop ' + window.document .body.scrollTop + '\n';
    alert(msg);
    }

    function scrollbarcheck( ) {
    var scrolling;
    if ((window.docume nt.body.scrollH eight >
    window.document .body.clientHei ght) ||
    (window.documen t.body.scrollWi dth >
    window.document .body.clientWid th))
    scrolling='true ';
    else
    scrolling='fals e';
    alert('scrollin g='+scrolling);
    }

    Mike

    Comment

    • mscir

      #3
      Re: scrollTo only if horizontal scrollbar

      mscir wrote:

      Sorry, that should have been:

      function showscrollfeatu res() {
      var wdb = window.document .body;
      var msg;
      msg += 'clientHeight ' + wdb.clientHeigh t + '\n';
      msg += 'clientWidth ' + wdb.clientWidth + '\n';
      msg += 'offsetHeight ' + wdb.offsetHeigh t + '\n';
      msg += 'offsetWidth ' + wdb.offsetWidth + '\n';
      msg += 'scrollHeight ' + wdb.scrollHeigh t + '\n';
      msg += 'scrollWidth ' + wdb.scrollWidth + '\n';
      msg += 'scrollLeft ' + wdb.scrollLeft + '\n';
      msg += 'scrollTop ' + wdb.scrollTop + '\n';
      alert(msg);
      }

      function scrollbarcheck( ) {
      var wdb = window.document .body;
      var scrolling;
      if ((wdb.scrollHei ght > wdb.clientHeigh t) ||
      (wdb.scrollWidt h > wdb.clientWidth ))
      alert('Scrollin g=True');
      else
      alert('Scrollin g=False');
      }

      Comment

      • anna

        #4
        Re: scrollTo only if horizontal scrollbar

        FOLLOWUP


        if (navigator.appN ame.indexOf("Ne tscape") != -1 &&
        parseFloat(navi gator.appVersio n) < 5 ) {
        if (document.width > window.innerWid th) {
        document.write( '<a
        href="javascrip t:window.scroll To(1000,window. pageYOffset)">< img
        src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
        src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
        }
        } else {
        if (document.body. scrollWidth > document.body.c lientWidth) {
        document.write( '<a
        href="javascrip t:window.scroll To(1000,documen t.body.scrollTo p)"><img
        src="/icons/redarrow.gif" border=0 alt="Scroll right"><img
        src="/icons/redarrow.gif" border=0 alt="Scroll right"></a>');
        }
        }

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: scrollTo only if horizontal scrollbar

          anna wrote:
          [color=blue]
          > [nonsense again][/color]

          See <news:408DC186. 8010700@Pointed Ears.de>


          PointedEars

          Comment

          Working...