Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 29-06-2009
Member
 
Join Date: Jan 2009
Posts: 39
Javascript reload image

Hi guys,
I want to reload a image using javascript, i know the way to reload the entire document but i only want to reload the image. Does some know how to do this?
Reply With Quote
  #2  
Old 29-06-2009
Member
 
Join Date: Oct 2005
Posts: 2,389
Re: Javascript reload image

Try the following code if does what you need:

Code:
<script type="text/javascript">
function reloadImage(){
if(document.images){
document.images['imageName'].src = 'Image.jpg?' +
Date.parse(new Date().toString());
} setTimeout(reloadImage,5000);
}
</script>
</head>

<body onload="reloadImage()">
<img name="imageName" src="Image.jpg">
Reply With Quote
  #3  
Old 29-06-2009
Member
 
Join Date: Mar 2008
Posts: 198
Re: Javascript reload image

The animation stops if the user moves around the page with a link like the one at the bottom of this page. Experienced users can force a reload to get the images going again, but the following JavaScript function can be used to ensure they are automatically restarted:

function reloadThePage() {
document.images[0].src=""
document.images[0].src="Dragon_Running.gif"
}

This is called by adding an onClick handler to FORM buttons or A anchor tags like this:

onClick="reloadThePage()"



See this page Javascript Reload Test
Reply With Quote
  #4  
Old 29-06-2009
Member
 
Join Date: Apr 2008
Posts: 2,001
Re: Javascript reload image

If you'll use your using setTimeout() , this will only change the image. You need to change the image and the attached link. You need to use setinterval() instead. And instead of having the setInterval() twice. Just use <body onload="clock()"> you alluded to), it will change the image and the link.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "Javascript reload image"
Thread Thread Starter Forum Replies Last Post
How to reload weapon in Serious Sam 3 Jasseen Video Games 6 05-10-2011 10:59 AM
How to keep rollover image onClick in javascript? MAGALY Software Development 4 08-03-2010 08:02 PM
Change Image and Update two frames in Javascript Sandy22 Software Development 3 10-12-2009 03:24 AM
How to create Javascript Image Rotation abbase Software Development 3 31-10-2009 01:48 PM
Upload image randomly with JavaScript Page Zubeen Software Development 3 25-02-2009 02:54 PM


All times are GMT +5.5. The time now is 11:38 AM.