Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

pictures don't show up on back button press

Status
Not open for further replies.

moron3

Technical User
Dec 2, 2008
17
US
The below code is used to load pictures on a webpage in the desired order.

It works great except when you hit the Back button in internet explorer 8 to go back to that page only the first image is still displayed, the rest of the images just show that little box you see when a picture hasn't loaded or can't be found.

Any ideas on how to get the pictures to display when the back button is pressed?

<html>
<body>
<p>Images:</p>
<img name=image0 onLoad="LoadImage('image1','number1.gif')">
<img name=image1 onLoad="LoadImage('image2','number2.gif')">
<img name=image2 onLoad="LoadImage('image3','number3.gif')">
<img name=image3>
End of document body.
</body>
<script type="text/javascript">
var loadingImage = false;
function LoadImage(imageName,imageFile)
{
if ((!document.images) || loadingImage) return;
loadingImage = true;
if (document.images[imageName].src.indexOf(imageFile)<0)
{
document.images[imageName].src = imageFile;
}
loadingImage = false;
}
LoadImage('image0','number0.gif');
</script>
</html>
 
Why bother with all that redundant code just to load 3 images in source order?

If you get rid of all the JS guff, keep it simple, and just have 3 plain old HTML image elements, they will still load in source order, and I'll bet any money you like that they will work correctly with the back button in IE8 as well.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top