aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes Different image reload in the page when i click in the refresh(f5) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Different image reload in the page when i click in the refresh(f5)" Watch "Different image reload in the page when i click in the refresh(f5)" New topic
Author

Different image reload in the page when i click in the refresh(f5)

s paul
Greenhorn

Joined: Jul 24, 2009
Posts: 4
Hi,

Different image reload in the page when i click in the refresh(f5) and also images will come in sequence... like img1 ,img2, img3... but not randomly...

Please give me the solution. it very Essential for me.

thank you.

Soumen
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Well you would need to store a cookie value with what index the person is on. When the page loads you read the cookie and you set the source of the image with a value from an array.

Eric
s paul
Greenhorn

Joined: Jul 24, 2009
Posts: 4
This is the code. please have a look.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Change Images</title>
</head>

<body>
<script language="JavaScript">
<!--
var how_many_ads = 3;
var now = new Date()
var sec = now.getSeconds()
var ad = sec % how_many_ads;
ad +=1;
//alert("VAL: " + ad);
if (ad==1) {
alt="PRIME definition"; banner="images/image1.jpg";
width="750";
height="500";
}
if (ad==2) {
alt="PRIME definition"; banner="images/image2.jpg";
width="750";
height="500";
}
if (ad==3) {
alt="PRIME definition"; banner="images/image3.jpg";
width="750"; height="500";
}
document.write('<center>');
document.write('<img src=\"' + banner + '\" width=')
document.write(width + ' height=' + height + ' ');
document.write('alt=\"' + alt + '\" border=0><br>');
document.write('</center>');
// -->
</script>
</body>
</html>


images should be come in sequence...like img1 ,img2, img3....... img1, img2. img3... for every refresh ... but not randomly... and work in all browser...

Please help me.

thanking you

soumen
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
When you post code here, please use code tags.

As I said before, you need to use a cookie to store the last value. When your code first loads you check the cookie and see if there is a value, if there is use it.

Eric
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Different image reload in the page when i click in the refresh(f5)