Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
156
rated 0 times [  160] [ 4]  / answers: 1 / hits: 32246  / 14 Years ago, thu, january 27, 2011, 12:00:00

HI everybody



i need to know if there are a way to change the background image after a specific time like 10 sec or 30 sec...etc.
you know like yahoo Login mail it's changing the background daily!!



if there is a way using JQuery or CSS or html or any other thing ,please tell me


More From » asp.net

 Answers
34

you can make it with javascript function



<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'>
var imageID=0;
function changeimage(every_seconds){
//change the image
if(!imageID){
document.getElementById(myimage).src=http://www.all-freeware.com/images/full/38943-nice_feathers_free_screensaver_desktop_screen_savers__nature.jpeg;
imageID++;
}
else{if(imageID==1){
document.getElementById(myimage).src=http://www.hickerphoto.com/data/media/186/flower-bouquet-nice_12128.jpg;
imageID++;
}else{if(imageID==2){
document.getElementById(myimage).src=http://www.photos.a-vsp.com/fotodb/14_green_cones.jpg;
imageID=0;
}}}
//call same function again for x of seconds
setTimeout(changeimage(+every_seconds+),((every_seconds)*1000));
}
</script>
</head>
<body style='background:black;' onload='changeimage(2)'>
<div style='position:absolute;width:100%;height:100%;left:0px;top:0px;' align='center'><img width='300px' height='250px' id='myimage' src='http://www.photos.a-vsp.com/fotodb/14_green_cones.jpg'/></div>
</body></html>


try this one! :)


[#94018] Wednesday, January 26, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
estefanib

Total Points: 508
Total Questions: 104
Total Answers: 83

Location: Lebanon
Member since Sun, Aug 2, 2020
4 Years ago
;