Jump to content
xisto Community
Sign in to follow this  
kvarnerexpress

Image Refresh

Recommended Posts

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

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

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

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. :P nevertheless, it's a good script if that is what you are looking for. :lol: 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

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
thanksImage Refresh

oh 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

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

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

the same stuff, but without recursion(self calling function)

setInterval( "doSomething()", 1000 );

function doSomething ( ){

 

}

Share this post


Link to post
Share on other sites
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

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.