Auto scroll to correct position?

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

    Auto scroll to correct position?

    I have a web page (IE only; intranet only) that is both wider and
    longer than the browser window. I've noticed that if the user has
    scrolled the page DOWN and then refreshes the page, the new page
    automatically scrolls down to same position. However, this automatic
    scrolling does NOT happen if the user has scrolled over towards the
    right side.

    Is there a setting that needs to be adjusted to get this to happen? Or
    something I need to do in the page?

    FWIW, I'm trying to come up with a script that will pass the
    ..scrollTop and .scrollLeft properties back to the server on a refresh
    (and then use .scrollTo to position the new page) but I'm hoping there
    might be a simpler way.

    Any suggestions?

    Thanks.
  • Yann-Erwan Perio

    #2
    Re: Auto scroll to correct position?

    Martin wrote:
    [color=blue]
    > I have a web page (IE only; intranet only) that is both wider and
    > longer than the browser window. I've noticed that if the user has
    > scrolled the page DOWN and then refreshes the page, the new page
    > automatically scrolls down to same position. However, this automatic
    > scrolling does NOT happen if the user has scrolled over towards the
    > right side.[/color]
    [color=blue]
    > FWIW, I'm trying to come up with a script that will pass the
    > .scrollTop and .scrollLeft properties back to the server on a refresh
    > (and then use .scrollTo to position the new page) but I'm hoping there
    > might be a simpler way.[/color]

    Since the full process is initiated by javascript, you should rather use
    client-side ways of state keeping, for instance cookies or frames - you
    could also consider IE behaviors (.htc files).

    There's also the following old IE thing (navigator expando), which runs
    happily in my current IE; that's probably more a hack than anything, but
    since it's been here for years it might as well be used, for instance as
    a js include - to be tested accordingly though, I seem to remember it
    crashing upon browser closing, but cannot remember the specifics of the
    test I tried then (long ago!).


    <script type="text/javascript">
    if(window.attac hEvent) {
    window.attachEv ent(
    "onbeforeunload ",
    function() {
    navigator.scrol lLeft=(
    document.compat Mode &&
    document.compat Mode.indexOf("C SS")!=-1 &&
    document.docume ntElement || document.body
    ).scrollLeft;
    }
    );

    window.attachEv ent(
    "onload",
    function() {
    if (typeof navigator.scrol lLeft!="undefin ed")
    scrollBy(naviga tor.scrollLeft) ;
    }
    );
    }

    //test
    for(var ii=0,s="";ii++< 100||document.w rite(s);s+=ii);
    </script>


    HTH
    Yep.

    Comment

    Working...