homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

Reload image on mouseclick
refresh image on click

Msg#: 4602017 posted 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.

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.



WebmasterWorld Senior Member 10+ Year Member

Msg#: 4602017 posted 4:11 pm on Aug 15, 2013 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved