happyPanda
Technical User
- Jul 21, 2008
- 2
I have a script that shows an image but the image goes away at a certain time. The problems I'm having are:
1. I want to make the images link to some site.
2. How do I use it for more than 1 image?
THis is the code:
1. I want to make the images link to some site.
2. How do I use it for more than 1 image?
THis is the code:
Code:
<html>
<head>
<script type="text/javascript">
function disappearImg(){
var dispT;
var now = new Date();
var yr = now.getFullYear();
var mn = now.getMonth();
var dy = now.getDate()
var hr = now.getHours();
var expiresyr = 2008;
var expiresmn = 6; // months 0 - 11
var expiresdy = 28;
var expireshr = 23;
var show = 0;
if (yr < expiresyr) {
show = 1;
}
if ((yr == expiresyr) && (mn < expiresmn)) {
show = 1;
}
if ((yr == expiresyr) && (mn == expiresmn) && (dy < expiresdy)) {
show = 1;
}
if ((yr == expiresyr) && (mn == expiresmn) && (dy == expiresdy) && (hr < expireshr)) {
show = 2;
}
if (show >= 1) {
dispT = "<img src='[URL unfurl="true"]http://codingforums.com/img/logo.gif'>";[/URL]
}
else {
dispT = "";
}
document.getElementById('imgDisplay').innerHTML = dispT;
if (show == 2) {
setTimeout("disappearImg",10000); // check every 10 seconds on expiry day until expiry time reached
}
}
</script>
</head>
<body onLoad="disappearImg()">
<div id="imgDisplay"></div>
</body>
</html>