Thanks,
that works great!

Lasse

-----Ursprüngliche Nachricht-----
Von: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] Im Auftrag von Matej Knopp
Gesendet: Montag, 1. August 2005 08:46
An: wicket-user@lists.sourceforge.net
Betreff: Re: [Wicket-user] Save and reload scrollposition

In one project, I did this using javascript, it worked fairy well. In 
each link I called function, that saved the scroll position as cookie 
and after refresh I reloaded the position and scrolled the document.

function setCookie(name, value, expires, path, domain, secure) {
        var curCookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
        document.cookie = curCookie;
}
                                
function getCookie(name) {
        var dc = document.cookie;
        var prefix = name + "=";
        var begin = dc.indexOf("; " + prefix);
        if (begin == -1) {
                begin = dc.indexOf(prefix);
                if (begin != 0) return null;
        } else {
                begin += 2;
        }
        var end = document.cookie.indexOf(";", begin);
        if (end == -1)
        end = dc.length;
        return unescape(dc.substring(begin + prefix.length, end));
}
                        
function deleteCookie(name, path, domain) {
        if (getCookie(name)) {
                document.cookie = name + "=" +
                ((path) ? "; path=" + path : "") +
                ((domain) ? "; domain=" + domain : "") +
                "; expires=Thu, 01-Jan-70 00:00:01 GMT";
        }
}
                        
function savePosition ()
{
        var offsetX = window.pageXOffset || document.body.scrollLeft || 
document.documentElement.scrollLeft;
        var offsetY = window.pageYOffset || document.body.scrollTop || 
document.documentElement.scrollTop;

        setCookie ('scrollOffsetX', offsetX);
        setCookie ('scrollOffsetY', offsetY);
}
                                                                
function loadPosition () {
        var x = getCookie ('scrollOffsetX');
        var y = getCookie ('scrollOffsetY');
        if (x && y) {
                window.scrollTo (x, y);
                deleteCookie ('scrollOffsetX');
                deleteCookie ('scrollOffsetY');
        }
}

Hope it helps.

-Matej

Martijn Dashorst wrote:
> Or use the JavaScript function 'focus()'?
> 
> Martijn
> 
> Jonathan Locke wrote:
> 
>>
>> just an idea... but maybe some fancy trick with anchor links?
>>
>> Phil Kulak wrote:
>>
>>> You mean you want the browser to have the exact same window position
>>> after the click? The best way would be to use JavaScript instead of a
>>> full page reload.
>>>
>>> On 7/31/05, pommeslk <[EMAIL PROTECTED]> wrote:
>>>  
>>>
>>>>
>>>>
>>>>
>>>> Hi,
>>>> in my application I have a table where each row can be selected for 
>>>> editing
>>>> like in Phils Weblog
>>>> (http://jroller.com/page/pKulak/20050729). But when I click
>>>> on the row I always start at the top of the page. How can I save the 
>>>> scroll
>>>> position and load it after the refresh? Is there any way to do it 
>>>> without
>>>> parameters and link to another instance of this page?
>>>> Any proposals?
>>>>  
>>>>
>>>>  
>>>>
>>>> Thanks,
>>>> Lasse
>>>>
>>>>   
>>>
>>>
>>>
>>>
>>> -------------------------------------------------------
>>> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>>> from IBM. Find simple to follow Roadmaps, straightforward articles,
>>> informative Webcasts and more! Get everything you need to get up to
>>> speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&opÌk
>>> _______________________________________________
>>> Wicket-user mailing list
>>> Wicket-user@lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>>
>>>  
>>>
>>
>>
>> -------------------------------------------------------
>> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
>> from IBM. Find simple to follow Roadmaps, straightforward articles,
>> informative Webcasts and more! Get everything you need to get up to
>> speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click
>> _______________________________________________
>> Wicket-user mailing list
>> Wicket-user@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/wicket-user
>>
> 
> 
> 
> -------------------------------------------------------
> SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
> from IBM. Find simple to follow Roadmaps, straightforward articles,
> informative Webcasts and more! Get everything you need to get up to
> speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> 



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=ick
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user



-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies
from IBM. Find simple to follow Roadmaps, straightforward articles,
informative Webcasts and more! Get everything you need to get up to
speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to