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…

<script type="text/javascript">
  var url = $(this).attr('href');

  $('#mydiv').fadeOut(1000, function(){
    document.location.href = url;

  return false;


Any help would be welcomed.

Many thanks,
cph :slight_smile:

use unload instead :

$(window).unload(function() {