SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2008
    Posts
    42
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    jquery transition on leaving page

    Hi Guys,

    I want to create a jquery effect where a div fades before exiting the page. I'm having trouble holding up the next page loading. This is what I have so far...

    HTML Code:
    <script type="text/javascript">
    $('a').click(function(){
      var url = $(this).attr('href');
    
      $('#mydiv').fadeOut(1000, function(){
        document.location.href = url;
      });
    
      return false;
    });
    
    </script>
    Any help would be welcomed.

    Many thanks,
    cph

  2. #2
    SitePoint Evangelist stonedeft's Avatar
    Join Date
    Aug 2009
    Posts
    590
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    use unload instead :
    Code JavaScript:
    $(window).unload(function() {
      $('#mydiv').fadeOut(1000);
    });
    Don't Panic


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •