Jump to content

Image Slideshow: Preventing a page from jumping back to the top of the browser


GeekyG

Recommended Posts

Hello,

 

I am using a modified script of PHPSlideshow (http://www.zinkwazi.com/wp/scripts/)

 

My modified version:

http://www.multimedia-designs.com/V3/phpslideshow/test/projects/indie/indie_titan.php

 

I got the layout and script to work the way I wanted it to (so I thought) and now I have ran into a new problem. Because the image slideshow is not at the top of the page, you have to scroll down in order to view the slideshow.

 

The problem: every time an end-user clicks on an image, the page jumps back to the top of the browser. I think I know why it does, because the script is fetching the next image and reloading it, which brings the page back to the top.

 

Is there a solution? Or am I wasting time. Can I prevent the page from jumping back to the top each time an image is clicked on?

 

Thanks, I am definitely a PHP beginner, and all help is appreciated.

 

Link to comment
Share on other sites

It jumps back because you simply load a new page. To overcome this, you can use javascript (AJAX) to load the pictures asynchronously, but then you have to use a completely different slideshow script (written in javascript). You should be able to find lots of examples on how to achieve this, though :)

Link to comment
Share on other sites

That's what I was afraid of, after all that work!

 

I was looking for a server-side solution because of people who disable JavaScript.

 

I guess now it is a toss-up between Flash or an Ajax (JavaScript) slideshow.

 

Anyone have an opinion on this?

 

 

Link to comment
Share on other sites

Well, I have an idea. You could keep your PHP, and use a HTML bookmark. Just put a name="something" in your anchor tag surrounding "start slideshow", and then put #something at the end of the links used to see the different images. It will then reload the page, and jump down to the "start slideshow" text.

 

<a href="/V3/phpslideshow/test/projects/indie/indie_titan.php?directory=.&auto=1&currentPic=1" name="something">start slideshow</a>

Link to comment
Share on other sites

There is no PHP solution around the jumping other than the one thebadbad posted. It will jump around as you say, but will bring the user back to the position in question everytime.

 

The only way around this is to implement an AJAX solution as thebadbad mentioned. However, if you are going to implement an AJAX solution, you should use both. Set up the PHP solution, and then overlay the AJAX solution on top of this. This way, if your users have javascript turned off, it will still work for them, although it wont look as pretty as if they have javascript turned on.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.