scrollbar

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter Fastré

    #1

    scrollbar

    Hello

    I want to display a link on the bottom of a webpage to go to the top,
    but only if the user has to scroll down. If there's a small page, this
    link has no use.

    I'm using the following code (in the body onload)
    var wdb = window.document .body;
    var scrolling;

    if (wdb.scrollHeig ht > wdb.clientHeigh t) {
    //alert('Scrollin g=True');
    document.getEle mentById('img_t otop').style.vi sibility
    = 'visible';
    }
    else {
    //alert('Scrollin g=False');
    document.getEle mentById('img_t otop').style.vi sibility
    = 'hidden';
    }


    It works on Internet Explorer, scrollHeight is bigger than clientHeight
    with a long page.
    But not in firefox, scrollHeight = clientHeight in all cases.
    What can I do about it?

    regards

    Peter
  • McKirahan

    #2
    Re: scrollbar

    "Peter Fastré" <peter.fastre@b elgacom.be> wrote in message
    news:%XS2e.5150 8$dn.3670030@ph obos.telenet-ops.be...[color=blue]
    > Hello
    >
    > I want to display a link on the bottom of a webpage to go to the top,
    > but only if the user has to scroll down. If there's a small page, this
    > link has no use.
    >
    > I'm using the following code (in the body onload)
    > var wdb = window.document .body;
    > var scrolling;
    >
    > if (wdb.scrollHeig ht > wdb.clientHeigh t) {
    > //alert('Scrollin g=True');
    > document.getEle mentById('img_t otop').style.vi sibility
    > = 'visible';
    > }
    > else {
    > //alert('Scrollin g=False');
    > document.getEle mentById('img_t otop').style.vi sibility
    > = 'hidden';
    > }
    >
    >
    > It works on Internet Explorer, scrollHeight is bigger than clientHeight
    > with a long page.
    > But not in firefox, scrollHeight = clientHeight in all cases.
    > What can I do about it?
    >
    > regards
    >
    > Peter[/color]



    Comment

    • McKirahan

      #3
      Re: scrollbar

      "Peter Fastré" <peter.fastre@b elgacom.be> wrote in message
      news:%XS2e.5150 8$dn.3670030@ph obos.telenet-ops.be...[color=blue]
      > Hello
      >
      > I want to display a link on the bottom of a webpage to go to the top,
      > but only if the user has to scroll down. If there's a small page, this
      > link has no use.
      >
      > I'm using the following code (in the body onload)
      > var wdb = window.document .body;
      > var scrolling;
      >
      > if (wdb.scrollHeig ht > wdb.clientHeigh t) {
      > //alert('Scrollin g=True');
      > document.getEle mentById('img_t otop').style.vi sibility
      > = 'visible';
      > }
      > else {
      > //alert('Scrollin g=False');
      > document.getEle mentById('img_t otop').style.vi sibility
      > = 'hidden';
      > }
      >
      >
      > It works on Internet Explorer, scrollHeight is bigger than clientHeight
      > with a long page.
      > But not in firefox, scrollHeight = clientHeight in all cases.
      > What can I do about it?
      >
      > regards
      >
      > Peter[/color]


      Won't this work for you:

      <body>
      <a name="top"></a>
      ..
      ..
      ..
      ..
      ..
      <a href="#top">top </a>
      </body>

      The link will always show but on a short page it does nothing.


      Comment

      • Peter Fastré

        #4
        Re: scrollbar

        McKirahan wrote:
        [color=blue]
        >
        > Won't this work for you:
        >
        > <body>
        > <a name="top"></a>
        > .
        > .
        > .
        > .
        > .
        > <a href="#top">top </a>
        > </body>
        >
        > The link will always show but on a short page it does nothing.
        >
        >[/color]
        I know, but I don't want the link to be shown, it makes no sense if the
        page is short.

        regards

        Peter

        Comment

        • McKirahan

          #5
          Re: scrollbar

          "Peter Fastré" <peter.fastre@b elgacom.be> wrote in message
          news:rKU2e.5155 7$vT6.3910800@p hobos.telenet-ops.be...[color=blue]
          > McKirahan wrote:
          >[color=green]
          > >
          > > Won't this work for you:
          > >
          > > <body>
          > > <a name="top"></a>
          > > .
          > > .
          > > .
          > > .
          > > .
          > > <a href="#top">top </a>
          > > </body>
          > >
          > > The link will always show but on a short page it does nothing.
          > >
          > >[/color]
          > I know, but I don't want the link to be shown, it makes no sense if the
          > page is short.
          >
          > regards
          >
          > Peter[/color]

          What dimension (in pixels) is a "short" page?

          If the browser window is resized by the visitor
          then the page may no longer be "short".


          Comment

          • Peter Fastré

            #6
            Re: scrollbar

            McKirahan wrote:
            [color=blue]
            >
            >
            > What dimension (in pixels) is a "short" page?
            >
            > If the browser window is resized by the visitor
            > then the page may no longer be "short".[/color]
            Short means to me, the page fits on the screen without scrollbars. It
            makes no sense showing a top link in this case.
            A long page means that the user has to scroll down to read everything,
            causing the menu and navigation on top of the page to disappear. Users
            want frames-websites, where navigation always stays on top. I have to
            convince them not to use frames, and the 'top' link is one of my
            arguments to drop the frames.

            Regards

            Peter

            Comment

            • McKirahan

              #7
              Re: scrollbar

              "Peter Fastré" <peter.fastre@b elgacom.be> wrote in message
              news:JgV2e.5157 1$LF.4101172@ph obos.telenet-ops.be...[color=blue]
              > McKirahan wrote:
              >[color=green]
              > >
              > >
              > > What dimension (in pixels) is a "short" page?
              > >
              > > If the browser window is resized by the visitor
              > > then the page may no longer be "short".[/color]
              >
              > Short means to me, the page fits on the screen without scrollbars. It
              > makes no sense showing a top link in this case.
              > A long page means that the user has to scroll down to read everything,
              > causing the menu and navigation on top of the page to disappear. Users
              > want frames-websites, where navigation always stays on top. I have to
              > convince them not to use frames, and the 'top' link is one of my
              > arguments to drop the frames.
              >
              > Regards
              >
              > Peter[/color]

              You didn't address my issue of resizing.

              "Users want frames-websites ..." --
              are you talking about your Users (or all Users)?

              A small "top" image that may not always be applicable
              is preferable to the use of scripting that may be disabled.

              Another argument against frames is how the print!


              Comment

              • RobB

                #8
                Re: scrollbar

                Peter Fastré wrote:[color=blue]
                > Hello
                >
                > I want to display a link on the bottom of a webpage to go to the top,[/color]
                [color=blue]
                > but only if the user has to scroll down. If there's a small page,[/color]
                this[color=blue]
                > link has no use.
                >
                > I'm using the following code (in the body onload)
                > var wdb = window.document .body;
                > var scrolling;
                >
                > if (wdb.scrollHeig ht > wdb.clientHeigh t) {
                > //alert('Scrollin g=True');
                > document.getEle mentById('img_t otop').style.vi sibility
                > = 'visible';
                > }
                > else {
                > //alert('Scrollin g=False');
                > document.getEle mentById('img_t otop').style.vi sibility
                > = 'hidden';
                > }
                >
                >
                > It works on Internet Explorer, scrollHeight is bigger than[/color]
                clientHeight[color=blue]
                > with a long page.
                > But not in firefox, scrollHeight = clientHeight in all cases.
                > What can I do about it?
                >
                > regards
                >
                > Peter[/color]

                This may need some fine-tuning.

                window.onload = function()
                {
                var bShow,
                el,
                dHt = self.innerHeigh t ? self.innerHeigh t :
                document.docume ntElement
                && document.docume ntElement.clien tHeight ?
                document.docume ntElement.clien tHeight :
                document.body ? document.body.c lientHeight : null;
                if (dHt && 'undefined' != typeof document.body.s crollHeight)
                {
                bShow = (document.body. scrollHeight > dHt);
                if (document.getEl ementById
                && (el = document.getEle mentById('img_t ­otop')))
                el.style.visibi lity = bShow ? 'visible' : 'hidden';
                }
                }

                Comment

                Working...