How to prevent scrolling to top of screen on reload?

adamsohn - October 3, 2009 - 15:43
Project:Gallery
Version:6.x-1.0
Component:Miscellaneous
Category:support request
Priority:minor
Assigned:Unassigned
Status:active
Description

When I click through the photo galleries the screen moves to the top of the page every time which means I have to scroll back down to the photo. How do I prevent this?

#1

lvthunder - October 4, 2009 - 04:59

I don't think you can. Each click loads a new page.

#2

adamsohn - October 4, 2009 - 05:29

I had installed the Album Photo module before and that is how it reloaded the pages. Might be javascript or something. When I reload firefox it doesn't move to the top either. There must be a way. If not how do people get around that?

#3

lvthunder - October 4, 2009 - 06:08

If you hit reload in Firefox it goes back because it knew you were there. Every album click in G2 is a new page. Firefox wouldn't know the difference between that and if you went to yahoo.com then clicked a link that took you to Google.

People get around it by making the top of the page small enough that you don't need to scroll down to see the pictures.

#4

Fohsap - October 4, 2009 - 17:07

That's just not true. There's like one or two pages for the entire gallery. The data's all called from a database. There's some way to lock the scroll bar when you refresh or browse to a new page, but it's a Javascript thing, I believe. You could probably do it in php, too? Try this google keyword: prevent scroll on reload. I wish I had time to figure it out myself, right now. I might be able to get some time in the next few days. If anyone finds a solution please post it. :)

#5

adamsohn - October 15, 2009 - 04:08

Sorry I don't have any more time to better explain this. If you have questions ask and I'll get back to you.

Added page anchor to gallery. Line 16 photo.tpl and lines 24, 34, 60, and 71 in galley2/modules/core/templates/blocks/navigtor.tpl.php This prevents the page from moving to the top as users browse through the image galleries.

<div id="gsContent"><a name="tophere"></a> //this is where the page will scroll to when loaded

    <a href="{g->url params=$navigator.next.urlParams}#tophere" class="next">
    <a href="{g->url params=$navigator.last.urlParams}#tophere" class="last">
    <a href="{g->url params=$navigator.first.urlParams}#tophere" class="first"> //these are the links that call the <a> tag with the name attribute.

 
 

Drupal is a registered trademark of Dries Buytaert.