Solved

Page transitions (fade in/out) with JQuery

Posted on 2008-10-26
3
8,507 Views
Last Modified: 2013-11-11
Hi everyone,

I was wondering if anyone had any good pointers for using JQuery to achieve page transitions (ie: Once page is loaded, page fades in, then on link click the page fades out and fades in the next page).

I have been using scriptaculous to achieve this with some success however I am finding that lots of componants are just flashing in order out so looking to change languages to something with a little bit more "punch" to it.

Any suggestions regardless of scripting language would be greatly appreciated. An example of my current scriptaculous page transition can be seen at www.richardmassey.com.au
0
Comment
Question by:RichardMass
  • 2
3 Comments
 
LVL 16

Expert Comment

by:sh0e
ID: 22809978
FYI, EE has a section for jQuery: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Jquery/#browseZones
Not to knock Scriptaculous, but I have found jQuery to be more compatible in general.

Here is how to hide, fade in, and fade out.
$(document.body).hide();
$(document.body).fadeIn();

$(document.body).fadeOut();
0
 
LVL 16

Accepted Solution

by:
sh0e earned 500 total points
ID: 22810014
jQuery has slightly different syntax from Prototype.  But you should be able to pick it up fast.  You might trip over yourself using the wrong syntax a little at first.

I took the liberty of writing a demo for you.
<html>
<head><title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
        jQuery('a').click(function(){
        jQuery(document.body).fadeOut();
        setTimeout("nav('"+this.href+"')",1500);
        return false;
    });
});
 
function nav(href){
 location.href=href;
}
</script>
</head>
<body>
<a href="test.html">test</a>
<a href="http://www.google.com">Google</a>
<a href="http://jquery.com">jQuery</a>
</body>
</html>

Open in new window

0
 
LVL 1

Author Closing Comment

by:RichardMass
ID: 31510159
That's fantastic, thank you so much. I've been able to pick your example apart and work out what does what and it has helped with playing with other functions as well.

Thank you heaps. I'm sure I will have more question on EE regarding JQuery but you have given me a great start.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question