Solved

Page transitions (fade in/out) with JQuery

Posted on 2008-10-26
3
8,505 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

911 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now