window scroll position

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

    window scroll position

    Ultimately what I need is a way to remember the scroll position of the form
    on a post back. I have a button that posts back to the current form and if
    there are no errors the form is reproduced, I want to scroll back to where
    the user was when they clicked on the button.

    I have an ASPX page with the following doc type:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd" >

    I'm not a 100% sure what all the above means, though I do know (from help
    with a co-worker) that it determines how the document is generated on the
    client side. I have to leave the doc type that way for our standards, but
    still need to do the following.

    I have the following JAVASCRIPT in the same page:

    alert("You've scrolled to " + document.body.s crollTop + " pixels.");

    With the doctype tag I always receive 0 for the value, but if I remove the
    doctype tag or set it to a different type, I receive the correct value. Is
    there an equivalent of scrollTop in the above doc type?

    Any help or points in the right direction are appreciated.
    Thanks
    Wayne


  • Wayne Sepega

    #2
    Re: window scroll position

    I had tried SmartNavigation (replaced with MaintainScrollP ositionOnPostba ck)
    before, but for some reason it to does not work. I have a GridView on my
    form that is tied to a large dataset (large in 30 or so rows), there are
    buttons that are dynamically created and when pressed call a javascript
    function. which looks like:

    function confirmIt(url)
    {
    location.href = url;
    }

    Which now that I think about it, looks more like a redirect then a postback.
    This could be why the above doesn't work for me.

    I did however find the following on the web:



    Last of the sample code shows hot to get the x, y of the scroll and then I
    also found



    Which had:

    window.scrollTo (x, y);

    This does the trick for me, for now. As I learn more and probably realize
    what is wrong with my location.href I'll work on correcting it so I can use
    the default property.

    Thanks
    Wayne



    "Steven" <Steven@discuss ions.microsoft. com> wrote in message
    news:B47810AF-1B49-4266-88C4-580E9C19BC39@mi crosoft.com...[color=blue]
    > If the users are using IE 5+ then set the DOCUMENT property of
    > 'smartNavigatio n' to true.
    >
    > "Wayne Sepega" wrote:
    >[color=green]
    >> Ultimately what I need is a way to remember the scroll position of the
    >> form
    >> on a post back. I have a button that posts back to the current form and
    >> if
    >> there are no errors the form is reproduced, I want to scroll back to
    >> where
    >> the user was when they clicked on the button.
    >>
    >> I have an ASPX page with the following doc type:
    >>
    >> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
    >> "http://www.w3.org/TR/html4/loose.dtd" >
    >>
    >> I'm not a 100% sure what all the above means, though I do know (from help
    >> with a co-worker) that it determines how the document is generated on the
    >> client side. I have to leave the doc type that way for our standards, but
    >> still need to do the following.
    >>
    >> I have the following JAVASCRIPT in the same page:
    >>
    >> alert("You've scrolled to " + document.body.s crollTop + " pixels.");
    >>
    >> With the doctype tag I always receive 0 for the value, but if I remove
    >> the
    >> doctype tag or set it to a different type, I receive the correct value.
    >> Is
    >> there an equivalent of scrollTop in the above doc type?
    >>
    >> Any help or points in the right direction are appreciated.
    >> Thanks
    >> Wayne
    >>
    >>
    >>[/color][/color]


    Comment

    Working...