kvarnerexpress 0 Report post Posted April 21, 2005 Hi all,Does anyone know if there is any way to refresh only an image in a webpage? I can't use the meta refresh because that would defeat the purpose of this page. If a link to this page is needed to see what I mean, let me know. I am using layers and they are dragable by visitors and if I refresh the whole page, the layers get reset.kvarnerexpress Share this post Link to post Share on other sites
sunster13 0 Report post Posted April 21, 2005 I don't fully understand what you mean, and a link would help.But if you go to http://internet.com/ they have some good scripts and you will probably find the solution there. Share this post Link to post Share on other sites
sunster13 0 Report post Posted April 21, 2005 o srry it's http://www.javascriptsource.com/srry bout that Share this post Link to post Share on other sites
round 0 Report post Posted April 22, 2005 i'm not sure what it is that your really trying to do, but from what i'm getting is that your looking for, or should be looking at an image rotation. I don't think there's a way of refreshing just one image on a page through js. Maybe you could do it with php.round Share this post Link to post Share on other sites
mizako 0 Report post Posted April 22, 2005 Hi all, Does anyone know if there is any way to refresh only an image in a webpage? I can't use the meta refresh because that would defeat the purpose of this page. If a link to this page is needed to see what I mean, let me know. I am using layers and they are dragable by visitors and if I refresh the whole page, the layers get reset. kvarnerexpress 132466[/snapback] What do you mean with refresh an image?. Change the image for another one, for example when the user clicks a link? If it is that it can be done with Javascript?Please, explain more detailed what it is exactlz what you want to do and maybe post a link. Share this post Link to post Share on other sites
serverph 0 Report post Posted April 22, 2005 check this out: http://forums.xisto.com/no_longer_exists/ related Xisto topic: http://forums.xisto.com/no_longer_exists/ i used that php rotator code in my site before, but since my site became popular (relatively ) and gained unexpected traffic, i took it off my site since it has been eating on my bandwidth. nevertheless, it's a good script if that is what you are looking for. otherwise, maybe try explaining a bit more so we can be certain of what you actually require for your site. Share this post Link to post Share on other sites
iGuest 3 Report post Posted October 9, 2007 SetInterval('reloadImage()', 30000); // 30 secondsThen, the reloadImage should replace the image thusly:function reloadImage(){ img = document.getElementById('theimage'); img.src = '/path/to/the/image/theimage.jpg?' + Math.random();}The Math.random() appended to the end of the image filename ensure that thebrowser will reload the image.-Singit.info Share this post Link to post Share on other sites
iGuest 3 Report post Posted December 29, 2009 thanksImage Refreshoh man... You saved my life !  quite good this feature using Math.Random()  I?d never thought about it, too simple and work perfectly.  thnx !  Najib El Alam Share this post Link to post Share on other sites
kshan 0 Report post Posted January 12, 2010 I am sorry but didnt get your quation. but may the below code will help you. <IMG src="image_name.jpg" width="275" height="200" border="1" name="refresh"> <script language="JavaScript" type="text/javascript"> <!-- var t = 120 // interval in seconds image = "image_name.jpg" //name of the image function Start() { tmp = new Date(); tmp = "?"+tmp.getTime() document.images["refresh"].src = image+tmp setTimeout("Start()", t*1000) } Start(); // --> </SCRIPT> Try this one - I use it to refresh my webcam pics. Just insert your on image address and interval time Notice from rvalkass: Added code tags around the code. Share this post Link to post Share on other sites
Semsem 0 Report post Posted January 12, 2010 Couldn't this also be done with AJAX? Share this post Link to post Share on other sites
BuffaloHelp 24 Report post Posted January 13, 2010 AJAX would have been fine. But Javascript is simpler. Either way, it's still client side running script. AJAX is basically javascript (client side running script) plus server side or base script (PHP, ASP, HTML etc). Share this post Link to post Share on other sites
iGuest 3 Report post Posted January 31, 2010 the same stuff, but without recursion(self calling function) setInterval( "doSomething()", 1000 ); function doSomething ( ){ Â } Share this post Link to post Share on other sites
iGuest 3 Report post Posted March 5, 2010 How to refresh image with valid size?Image RefreshReplying to kshanHello Gurus, I need your help.I have a program that saves images with the same name (say: image.Jpg) each second.The web browser needs to show and refresh this image also each second.The proble is the collision, when the browser tries to to load the image that is being saved at the moment. This results in a flicker, a broken up picture, etc.So I need to know how to change the code you provided (see below) thatWill prevent to reload when the file is being written.I guess, before displaying it the program should see the file size or something like that.Thank you so much. Peterimage_name.Jpg-reply by Peter Share this post Link to post Share on other sites
Rigaudon 0 Report post Posted April 9, 2010 I'm not completely sure I understand what you're trying to do, but here's my interpretation: If there's a picture, load it, otherwise keep it the same if it's being written. Right?If that's the case, you'd need AJAX. Make your basic AJAX functions and set the intervals at 1 second each. In the PHP file, check to see if there is a file with file_exists() and that name.I'm not completely sure if file_exists() returns true when it's being rewritten, but my best guess is that it does. I can post the code if you need me to. Good luck! Share this post Link to post Share on other sites
iGuest 3 Report post Posted August 4, 2010 Just to tidy up kshan's code <img src="image_name.jpg" width="275" height="200" border="1" name="refresh"> <script language="JavaScript" type="text/javascript"> <!-- var t = 120 // interval in seconds function Start() { document.images["refresh"].src = document.images["refresh"].src+"?"+Math.random() setTimeout("Start()", t*1000) } Start(); // --> </script> Share this post Link to post Share on other sites