View Single Post
  #3 (permalink)  
Old March 4th, 2010, 12:15 AM
PeterPeiGuo PeterPeiGuo is offline
Friend of Wrox
 
Join Date: Dec 2008
Location: , , .
Posts: 238
Thanks: 2
Thanked 20 Times in 19 Posts
Default

I guess that history.go(-2) was an attempt to go back to image 1 when it is on image 3 (1 - 3 = -2).

However that won't work , as the page never went forwardly or backwardly. Although the image changed, it was always the "same page".

use the following code, and follow the test sequence specified below, you will see what history.go(-2) actually does.
Code:
function switchImage()
{
	if(currentImgNumber < numberOfImages)
	{
		document.imgAdvert.src = ++ currentImgNumber + '.jpeg';
	} else if (currentImgNumber == numberOfImages) {
		history.go(-2);
	} 
	setTimeout("switchImage()",3000);   
}
Steps for testing:
  1. visit www.cnn.com (this is page 1)
  2. visit www.abcnews.com (this is page 2)
  3. visit the testing page (this is page 3, and remains as page 3 while the image changes)
  4. Wait until you see the last page, wait for 3 more seconds, you will be led back to www.cnn.com

Last edited by PeterPeiGuo; March 4th, 2010 at 12:30 AM..
Reply With Quote