Jai
Jai

Reputation: 2204

Is there a way to maintain the scrollbar position On a page refresh (Without Javascript)?

I am building a system where users can edit content inline, however a requirement of the project is:

No Javascript!

Is there a way using just php, html and css to maintain the scrollbar position on a page refresh so when an edit button is clicked the page doesn't jump up to the top?

any suggestions?

Upvotes: 0

Views: 1734

Answers (2)

jfriend00
jfriend00

Reputation: 707446

This sounds like the perfect place for progressive enhancement. If there is no javascript, then use the named anchor tag (as Olli mentions) and a hash on the URL to get it close (but it won't be exact).

If there is javascript, then save the scroll position to a cookie or URL parameter and restore the scroll position exactly when the page reloads.

There should be no harm in offering the best experience you can without javascript, but offering a better one when javascript is available (progressive enhancement).

Another possibility is to use a paged or tabbed interface (to position the edit field near the top of the window) so it's a lot less likely that there is any scrolling when the field is edited.

Upvotes: 5

Olli
Olli

Reputation: 752

Do it so:

<a name="jumphere"></a>

and when you have edited

http://yourUrlHere.com/somepage.php#jumphere

Upvotes: 3

Related Questions