Forum Moderators: open

Message Too Old, No Replies

save scroll position in cookie for postback

         

wmbrae

12:56 am on Apr 8, 2008 (gmt 0)

10+ Year Member



I trying to make a javascript document reader in 2 frames.
The left frame displays the document, the right frame shows a list of document links.

Does anybody have one ready made?

I'd like to load the document and move the scroll position to where it was last viewed.
Can anyone suggest terms used to describe what i am trying to do, so I can search scripts?
The most relevant search results so far are "scroll position postback" but I haven't found any good scripts because there are so many issues regarding browser compatibility and ASP, PHP.

I was wondering if scroll position (scrollx, scrolly) captured by continually running timer driven sampler or some on condition, stored in a cookie would work?

Any suggestions?

[edited by: tedster at 2:30 am (utc) on April 8, 2008]
[edit reason] no personal urls, please [/edit]

httpwebwitch

2:09 am on Apr 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I doubt you'll find any open-source code to do this, it's a rather custom sort of behaviour. You're better off coding it from scratch.

your idea sounds like a good one; latch onto the unload event of the window, and when the page unloads, write the current scrollX into a cookie.

beware that a cookie is sent along with every HTTP request, so if this scrolling script is running on other pages it may exhibit unexpected behaviour

DrDoc

3:58 am on Apr 8, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Indeed ... you are unlikely to find a free script that does this. But, it wouldn't be hard to create on your own. In fact, simply follow httpwebwitch's suggestions above. And, no need to worry about PHP vs ASP vs whatever, as this will be completely client-side code.