Entry
How do I force the web browser always display the current contents of a gif after its contents change but not its name ?
Jul 28th, 2001 01:17
Vipin Gupta, Yvan Taviaud, Juergen Thelen, joe guo,
Hi,
I hope that I got your question right, but it sounds to me that you're
talking about right clicking an image and selecting properties in your
browsers context menu. And you want to prevent a file name beeing shown
there, right?
I don't know of any javascript function able to do this kind of stuff,
and honestly I would be suprised if there is, because javascript
usually is not beeing used to change browser internal behaviours...
On IE maybe there's a way doing this using HTAs, but for cross browser
the only thing that comes to my mind is to block the context menu.
This can be done by trapping right clicks. Just have a look at
http://www.faqts.com/knowledge_base/view.phtml/aid/5693/fid/126
to see how this works.
Hope this helps.
Juergen
Other solution (Added on July 28th 2001), by Yvan:
I think your problem is that the image doesn't refresh whereas its
content has changed. That's because the image is in the cache, so as
long as its name doesn't change, the browser think it's the same as
before. To avoid this, you can easily do this:
(NN4+, IE4+)
<BODY
onload="document.images.img_gif.src='your_path_to_the_file/the_image_fil
e?' + Math.floor(Math.random() * 1000);">
<IMG name="img_gif" src="">
That just add an '?' and a random number after the filename, so that
the browser think the image is another one. Simple, isn't it?
Another thing you can do:
<IMG name="img_gif" src="image.gif">
<A href=# onclick="document.images.img_gif.src='image.gif?' + Math.floor
(Math.random() * 1000);">Refresh image</A>
Then when you click on 'Refresh image' the image would refresh.
Hope this helps,
Yvan