Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 1st, 2005, 5:31 PM   #1
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
Force Image Refresh

Is there an easy way to force a page to always download an image using javascript?
Ghost is offline   Reply With Quote
Old Dec 1st, 2005, 5:40 PM   #2
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
(NN4+, IE4+)

<BODY
onload="document.images.img_gif.src='your_path_to_the_file/the_image_fil
e.gif?' + Math.floor(Math.random() * 1000);">
<IMG name="img_gif" src="">

If anyone else has the same question, here is an answer I discovered that works well.
Ghost is offline   Reply With Quote
Old Dec 2nd, 2005, 6:54 AM   #3
Agent 47
Hobbyist Programmer
 
Agent 47's Avatar
 
Join Date: Nov 2005
Posts: 122
Rep Power: 3 Agent 47 is on a distinguished road
Quote:
Originally Posted by Ghost
(NN4+, IE4+)

<BODY
onload="document.images.img_gif.src='your_path_to_the_file/the_image_fil
e.gif?' + Math.floor(Math.random() * 1000);">
<IMG name="img_gif" src="">

If anyone else has the same question, here is an answer I discovered that works well.
Actually, there is a chance, albeit minute, that this will generate the
same number twice in succession, and thus display the same image.

A better solution it to append a timestamp to the url in the same way.

--47.
__________________
"I'm going to become rich and famous when I invent a device that allows you to stab people in the face over the internet"
Agent 47 is offline   Reply With Quote
Old Dec 2nd, 2005, 11:12 AM   #4
Ghost
Man Bear Pig Hunter
 
Ghost's Avatar
 
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4 Ghost is on a distinguished road
That is a basic mythod I found, becayse I use ASP.NET I do a timestamp OnPreRender, so for me it works out well, because that is when the image is given its url for it's src from the database.
Ghost is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:29 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC