/    Sign up×
Community /Pin to ProfileBookmark

Show image while page unloads

I want to show an image on my webpage while a page unloads.

such as… Someone is on my webpage. They then type an address in to go somewhere else… or click a link to go somewhere else. When the page unloads. I want an image to show until the other page loads.

What is the best way to do this?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@firmanauthorJul 21.2008 — Just thought I would bump this to the top hoping for some help please.
Copy linkTweet thisAlerts:
@HoboScriptJul 21.2008 — I don't think that's how it works. You could achieve this, by hijacking the session (meaning make it impossible for the user to leave your domain), by calling a onbeforeunload event that cancels the request and handles the page loading by some ajax function. Then while the new page is being downloaded show your image and then replace all the HTML with the new site content.

This is a basic idea of how this would work. Otherwise if you use the onbeforeunload event and show an image it will only appear for like a second and then a request is made for the new site that will wipe the page and then load the new contents.

I may be incorrect on this, but I also feel anything you attempt will be impeded by browser limitations, such as Opera's inability to have any onbeforeunload events.
Copy linkTweet thisAlerts:
@firmanauthorJul 21.2008 — I do not want to hijack their session.. What happens, is when a user is on my intranet site, and click to go to another query... It takes a while to load... I would just like an image to come up that says loading on the page until the next one loads.
Copy linkTweet thisAlerts:
@HoboScriptJul 21.2008 — And I'm saying that the only way to do that without frames is to buffer the next site by hijacking the session.

In fact I don't even think you can do that with frames.... easily.
×

Success!

Help @firman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...