PDA

View Full Version : conveyor belt help - no restart in ie?



gregorw
07-20-2008, 07:20 PM
1) Script Title: Conveyor Belt Slideshow

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/leftrightslide.htm

3) Describe problem: I have this script configured and working well (got some left/right/pause controls working, if anyone's interested: www.gregorw.com/conveyor.html), but am looking for one additional tweak to make it perfect. In Firefox, if I click one of the hyperlinked images and navigate away from the page, when I return to the site the slideshow picks up where it left off. In IE7 though, the slideshow starts over. Any way to make IE behave like Firefox in this respect?

thanks,

GW

jscheuer1
07-21-2008, 03:04 PM
That's a peculiarity of the browsers' back buttons and how they treat scripts on the page being moved back to. Opera behaves the same way as FF in this regard with your page. However, with some scripts this feature will act differently in FF and Opera. And with some scripts it will result in the page being navigated to via the back or forward buttons of the browser unstable or unusable unless and until the page is refreshed by the user. IE almost always restarts scripts from scratch when hitting the back button, as if the page were being navigated to for the first time. This is generally the safest way to treat scripts during the forward and backward browser button navigation process because, although it doesn't pick up where it left off, it at least renders the retrieved page properly in most cases.

You can get IE to pick up where it left off with a script by saving key pieces of data from the script in a cookie and then retrieving them from the cookie and using them to recreate the state of the script the next time the page is visited.

For example, you would probably want to save the the direction and position of the two moving divisions and retrieve that data (when it exists) for use during the execution of the fillup function.

Here is a good primer on cookies with sample routines that can be used to set and retrieve the value(s) you want to work with:

http://www.quirksmode.org/js/cookies.html

Using cookies in this manner will generally make all browsers pick up where they left off, regardless of how the page is navigated to.