Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"Because of this forum, I continue to WOW! my clients!"

Geography

Where in the world do Tek-Tips members come from?

How can I refresh an image without refreshing the whole page?Helpful Member! 

texnut (IS/IT--Management)
4 May 09 16:20
Hello all - I'm very new to web development so please forgive any tech mistakes I might be making ahead of time.

I have a program that writes an image file to disk every 5 secs.  It's the same image file.  So for example, the file image1.jpg is overwritten every five seconds with new data.

I would like to write a web page around this image such that the image automatically updates itself without the user having to refresh the page.

I'm assuming that AJAX might be the way to go, but I might be totally wrong.

Does anyone know how to do this?

Many thanks in advance
Helpful Member!  feherke (Programmer)
5 May 09 3:05
Hi

I would say, there is no need for Ajax. Regular JavaScript is enough :

CODE --> JavaScript

var reimg
window.onload=function () {
  reimg=document.getElementById('re')
  setInterval(function () {
    reimg.src=reimg.src.replace(/\?.*/,function () {
      return '?'+new Date()
    })
  },5000)
}

CODE --> HTML

<img src="yourimage.png?" id="re">

Feherke.
http://rootshell.be/~feherke/

texnut (IS/IT--Management)
5 May 09 10:19
Feherke,

Thanks for the code snippet!  I'm going to give it a test later in the afternoon and will post back with results.  Thanks again!

Salim
texnut (IS/IT--Management)
5 May 09 14:23
Feherke, it worked!  Thats a load!

Salim

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close