Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Old 11-07-2010, 12:41 PM Fade Between Pages
Physicsguy's Avatar
404 - Title not found

Posts: 919
Name: Scott Kaye
Location: Ontario
Trades: 0
Not exactly the most widely used - example, but this works really well!

I've seen a lot of fade between pages things, but none of them work as simply as I had hoped. This is super simple. Special thanks to the members of WT who helped me with this script!

Code:
<body onload="fadeIn()">
<script type="text/javascript">
  $(document).ready(function(){
            var fadeTime = 300;
    $(window).load(function() {
        $('body').hide();
        $('body').fadeIn(fadeTime);
    });
  });
    $(document).ready(function() {
        var loader;
        $('a').bind("click", function(){  
            var pageURL = $(this).attr('href');
            $('body').stop(true, true);
            $('body').fadeOut(fadeTime);
            window.clearTimeout(loader);
            loader = window.setTimeout(function() {
                    window.location=pageURL;
                $('body').fadeIn(fadeTime);
                loading = false;
            }, fadeTime);
            return false;
        });
    });
    </script>
That will fade the body element in and out! And it works on any page, just pop this code in any page you want to fade in/out and BAM. There you go.

The thing I wanted to make this for was because most of the other page fade scripts used AJAX to fetch the next page's URL and load it into a div. That sucks, because the URL stays the same, making it bad for SEO. This way you can have all your normal pages, but also have that nice added fade effect.

Now tell me how stupid I am and that everybody already knows it. **usually what happens when I post scripts I made ;P**
__________________
Check out my
Please login or register to view this content. Registration is FREE
or my
Please login or register to view this content. Registration is FREE
!
Physicsguy is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to Fade Between Pages
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15665 seconds with 12 queries