I want to create a html/javascript page that displays a splash image (splash.jpg) until there is an image file (latest.jpg) has been overwritten.
I want to display this latest.jpg for 90 seconds and then switch back to splash.jpg until the new latest.jpg file is overwritten.
I wish I could show what I’ve have thus far but I’ve tried a many different methods of accomplishing this and not sure I know which one is most practical or efficient.
I’ve tried several pieces found here and elsewhere.
2
Answers
I’m not sure what you’re trying to accomplish, but going off what you said a common simple solution is to continuously ping the server for a new version of a file with ajax on the browser. If you want to get more complicated you could use WebSockets but that may be overkill for what you’re trying to do.
I recommend you have a .txt file with a hash of the image on the server that the browser ajax can check to save bandwidth.
Example code:
Html
Javascript (uses jQuery)
Your server environment should update the hash.txt file to contain the hash of the latest.jpg image when it updates.