Welcome to WebmasterWorld Guest from 54.161.228.30

Forum Moderators: open

Message Too Old, No Replies

Reload image on mouseclick

refresh image on click

   
1:03 am on Aug 15, 2013 (gmt 0)



Hello, i want to assign an id (refresh/reload) to an image and when i click a button/link, i want the images that contain the reload id, to reload the image....

Also, if possible, make the image with the id to reload every 60 seconds.

This should be very simple but i cant find any solutions on the web.
I already posted on phpfreaks but no one answered and their site seems down.

Thanks in advance.

EDIT:
I have these images i want reloaded in a div (<div id="page-body">)
If i could just load that div, it would be enough.

Im on a free server and i want to avoid often page refreshes so i want to reload just the link-image on the user's side.
4:11 pm on Aug 15, 2013 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Reloading or refreshing an image can be just a little complicated. Since the DOM 'image' object doesn't have a .refresh() method, you pretty much have to use some brute force to get the browser to do it. The most popular approach seems to be dynamically adding (or changing) a query string in the URL of the img 'src' so that the browser doesn't see a cached copy of the image and requests the "new" image from the server. A dummy variable that holds an incrementing counter or a timestamp is sufficient. If you search on "javascript image reload" you'll find some examples that include timing controls.