Top.Mail.Ru
? ?
Javascript's Journal
 
[Most Recent Entries] [Calendar View] [Friends View]

Wednesday, July 2nd, 2003

Time Event
12:20p
STUFT
(Save the users from themselves.)

I was preparing some wallpaper images, and it occurred to me that some of the viewers of the site may try to save an image before it finishes loading. Here's my solution.

Create a "Loading..." page that loads the image in the background (presumably caching it), and then redirects to a page displaying the image. The simplest way is just to specify the image size as 1x1:

<img width='1' height='1' src='some_image.jpg'>

Then, when it's loaded, redirect to a page displaying the image and instructions. Add this to the <img> tag:

onload='window.location.href="some_page.html";'

And just in case anything goes wrong, you can create a page with an error message, and add this to the <img> tag:

onerror='window.location.href="error.html";'


See it in action.

<< Previous Day 2003/07/02
[Calendar]
Next Day >>
About LiveJournal.com
Image