On a site I recently worked on I wanted to have an animation before the next page loaded. What I wanted to happen was: user clicks a link, animation plays out, page is loaded normally. It is a nice little effect, but this is probably a trick you want to use sparingly…please…use it sparingly.

This uses the delay, and easing plugins for jquery. The below example includes the animation just as an example.

$('#link').click(function(){
        // Get the url of the link
		var toLoad = $(this).attr('href');

			// Do some stuff
			$(this).animate({
				marginRight: '50px',
				marginLeft: '-175px'
			}, 300, 'easeOutSine').animate({
				marginRight: '-38px',
				marginLeft: '-120px'
			}, 500, 'easeOutBounce');
			// Stop doing stuff

        // Wait 700ms before loading the url
		$(this).delay(700, function(){
			window.location = toLoad;
		});

        // Don't let the link do its natural thing
		return false;
});