I am creating a simple splash page with the following sequence:
- Fade in elements
- Wait 5 seconds
- Fade out elements
- Launch new page
I can get steps 1 through 3 to work properly in sequence.
However, as soon as I add a url redirection to my chain (step 4), it runs steps 1 to 3 super quickly and jumps. Here’s the code I’m using:
<html>
<head>
<style type="text/css">
.splash p { background: yellow; display: none; }
</style>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
<script type="text/javascript">
$.fn.go_homebase = function() {
var url = "homebase.html";
$(location).attr('href',url);
}
$(document).ready(function() {
$('.splash p').fadeIn('slow').delay(5000).fadeOut('slow').go_homebase();
});
</script>
</head>
<body class="splash">
<p>Splash Page!</p>
</body>
</html>
Is there a proper and better way I should be doing this?
you should call
go_homebasein the complete callback offadeOut, e.g.: