scrollbar

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

    scrollbar

    is there a method to get scrollbar position?
  • Thomas 'PointedEars' Lahn

    #2
    Re: scrollbar

    Cool Mentalist wrote:
    [color=blue]
    > is there a method to get scrollbar position?[/color]

    window.pageXOff set
    window.pageYOff set


    PointedEars

    Comment

    • Michael Winter

      #3
      Re: scrollbar

      "Thomas 'PointedEars' Lahn" wrote on 12/11/2003:
      [color=blue]
      > Cool Mentalist wrote:
      >[color=green]
      > > is there a method to get scrollbar position?[/color]
      >
      > window.pageXOff set
      > window.pageYOff set[/color]

      Is the IE implementation of those properies broken or missing? I get
      'undefined' with both. The same holds true with the x and y
      properties of Link and Anchor objects. However, the x and y
      properties of the event object have values.

      Mike

      --
      Michael Winter
      M.Winter@[no-spam]blueyonder.co.u k (remove [no-spam] to reply)


      Comment

      • Richard Cornford

        #4
        Re: scrollbar

        "Michael Winter" <M.Winter@[no-spam]blueyonder.co.u k> wrote in message
        news:g5Asb.2321 $Xf6.15996986@n ews-text.cableinet. net...[color=blue]
        > "Thomas 'PointedEars' Lahn" wrote on 12/11/2003:
        >[color=green]
        > > Cool Mentalist wrote:
        > >[color=darkred]
        > > > is there a method to get scrollbar position?[/color]
        > >
        > > window.pageXOff set
        > > window.pageYOff set[/color]
        >
        >Is the IE implementation of those properies broken or missing?[/color]
        <snip>

        IE does not implement them at all. They are the preferred values to read
        but if absent (so in IE) the scrollTop and scrollLeft values can be read
        from the root element. Exactly which element is the root element depends
        on the browser/version _and_ (if it exists) the "compatMode ".

        In the absence of pageXOffset/YOffset value I would test to see if
        document.compat Mode is defined, if it is not then the root element is
        document.body. If it is defined and holds the string value "CSS1Compat "
        then the root element is document.docume ntElement (the HTML element) and
        the scroll values should be read from there. Any other values of
        document.compat Mode ("BackCompat ", "QuirksMode ", etc) mean that
        document.body is still the root element and it should be read for the
        required values.

        Richard.


        Comment

        • Cool Mentalist

          #5
          Re: scrollbar

          I used document.body.s crollTop and it worked a treat. I take it i should put in
          pageXOffset for other browsers tho.

          Nick

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: scrollbar

            Cool Mentalist wrote:
            [color=blue]
            > I used document.body.s crollTop and it worked a treat.
            > I take it i should put in pageXOffset for other browsers tho.[/color]

            Yes, you should:

            if (typeof pageXOffset != "undefined" )
            {
            ... pageXOffset ...
            }
            else if (/* test suggested by Richard */)
            {
            ... referenceToRoot Element.scrollT op ...
            }


            HTH

            PointedEars

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: scrollbar

              Cool Mentalist wrote:
              [color=blue]
              > I used document.body.s crollTop and it worked a treat.
              > I take it i should put in pageXOffset for other browsers tho.[/color]

              Yes, you should:

              if (typeof pageYOffset != "undefined" )
              {
              ... pageYOffset ...
              }
              else if (/* test suggested by Richard */)
              {
              ... referenceToRoot Element.scrollT op ...
              }


              The same goes for `pageXOffset' and `scrollLeft'.


              HTH

              PointedEars

              Comment

              Working...