Fade out when user leaves page — jquery
Posted
by
Tom Julian Hume
on Stack Overflow
See other posts from Stack Overflow
or by Tom Julian Hume
Published on 2012-09-25T21:17:22Z
Indexed on
2012/09/25
21:37 UTC
Read the original article
Hit count: 539
I have some simple page transitions that fade in, once the user has landed. However, I'm also trying to make the same page fade out, when the user leaves.
I have found a few solutions, but they appeared to use delay(). Are there any that don't?
Thanks for any help, (I'm new to this, mind!)
Tom :)
I am currently using this code:
$(document).ready(
function(){
$( 'body' ).fadeIn(2000);
$('#stop').click(function (e) {
e.preventDefault(); });
$('#clients').click(function() {
$("#projectinfo").slideUp('slow');
$("#us").fadeOut('slow');
$("ul").fadeToggle('slow'); });
$('#information').click(function() {
$("#projectinfo").slideUp('slow');
$("ul").fadeOut('slow');
$("#us").fadeToggle('slow'); });
$('#question').click(function() {
$("#projectinfo").slideToggle('slow'); });
$('#question').hover(function() {
$("#projectinfo").slideToggle('slow'); });
$("a").click(function(event){
event.preventDefault();
linkLocation = this.href;
$("body").fadeOut(1000, redirectPage);
});
function redirectPage() {
});
© Stack Overflow or respective owner