Reputation: 1
I'm trying to make a jquery script that makes the page fade out before leaving it. can anyone help?
Upvotes: 0
Views: 180
Reputation: 129792
I think this would be the least obtrusive way. It simply fades out the page just before unload, regardless of whether the unload is caused by F5, navigating to another page, closing the browser window, or clicking a link.
window.onbeforeunload = function() { $(document.body).fadeOut() }
If you just want it for special links, tho, you could try this:
$('a.withFade').live('click', function() {
var url = $(this).attr('href');
$(document.body).fadeOut('1000', function() {
location.href = url;
});
return false;
});
Upvotes: 6