Skip to content Skip to sidebar Skip to footer

Fade Between Pages Using Jquery

I'm trying to add a transition effect to my site with Jquery. Everything was working, but suddenly the site started flickering one time before the fade in effect... I add a display

Solution 1:

You can perform the fade in transition using CSS only, like so:

body {
    animation: myfadeInAnimation 2s;
}
div {
    width: 300px;
}
@keyframe myfadeInAnimation {
    from {opacity: 0;}
    to {opacity: 1;}
}
@-webkit-keyframes myfadeInAnimation {
    from {opacity: 0;}
    to {opacity: 1;}
}

Here is the JSFiddle demo

As for the fade out effect, if the browser will not be running javascript, you will have no means of detecting the window unload and trigger an effect for it...

Solution 2:

For javascript disabled : You can add this to your page,so user wont be able to see anything rather than a blank page and a useful message

<noscript>
         Javascript is not enabled on browser and require this to be enabled to function properly.
         Here are the <ahref="http://www.enable-javascript.com/"target="_blank">
         instructions how to enable JavaScript in your web browser</a>.
         <!-- <meta http-equiv="refresh" content="0;url=http://www.enable-javascript.com/">--><styletype="text/css">div.container { display:none;}
          </style></noscript>

assuming every thing is inside your container

Post a Comment for "Fade Between Pages Using Jquery"