INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Simple HTML with automatic image refresh

Simple HTML with automatic image refresh

(OP)
Hi,

I am very new javascript and webpage development. Can you please help me with following webpage ?

The webpage should contain a simple image element which should refresh with the most recent image in a directory. Can someone please share the required HTML and javascript code for the same ?

RE: Simple HTML with automatic image refresh

forum215: HTML, XHTML & CSS
forum253: -Web site designers

<meta http-equiv="refresh" content="5"> Refreshes the page every five seconds.

Makes it completely useless for visitors as does ANY automatic refresh system.


What you need is NOT managed by javascript but needs to be set on your server (cache headers and expiry times.)


Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.
Webmaster Forum

RE: Simple HTML with automatic image refresh

Your request does not really make sense.

Javascript generally has no access to directory functions either on the server or on the client. So no way for it to really tell if an image file is new or not in any way.

Usually, as Chris points out, this is done via html headers in the website code. That tell the browser to go fetch the image every time, instead of using its local cache. Which means if the image file is updated, it will be loaded from server every time (assuming the image keeps the same file name).

If you are adding image files with different names and always want the newest one, that would be more server side code task such as PHP or ASP. But definitely not Javascript.









----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech

RE: Simple HTML with automatic image refresh

Quote:

But definitely not Javascript.
Well you could add a dynamic unique query string var to the img source path to create an un-cached URL.

I use this technique server side to add a version number GET argument to resources, so the browser is forced to reload a script or css to ensure latest version is being used.

"In complete darkness we are all the same, it is only our knowledge and wisdom that separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!"
Free Electronic Dance Music

RE: Simple HTML with automatic image refresh

Hi

Quote (1DMF)

Quote:

But definitely not Javascript.
Well you could add a dynamic unique query string var to the img source path to create an un-cached URL.
Given that

Quote (JASONHEADSETSDOTCOM)

refresh with the most recent image in a directory
how will JavaScript alone guess the name of the latest image file ?

( Of course, if the question actually means "refresh with the most recent content of the same image file in a directory", then is indeed doable with JavaScript alone. )

Feherke.
feherke.ga

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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!

Resources

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