javascript - smooth transition between pages when redirecting with jquery -
i trying smooth transition when redirect users. first fading out page redirecting , and fadein.
here redirect
if ( data.redirect != undefined ) { $("#toppanel").slideup(1000); $("#content").fadeout(2000, function() { window.location = data.redirect; }); my next page has javascript in header this:
jquery(function ($) { $("div.container_16").first().hide(); $(".grid_16").first().hide(); $("div.container_16").first().fadein(2000); $(".grid_16").first().slidedown(4000); this work except few milli sec second page loads turns blank , fades in. how fix this? need change css or html?
a simple fix be:
css
body{ display:none; } js
jquery(function ($) { $('body').show(); $("div.container_16").first().hide(); $(".grid_16").first().hide(); $("div.container_16").first().fadein(2000); $(".grid_16").first().slidedown(4000); } you should know 1 second lot of time web user. , taking 6s move page costly user base. hope offer solution without these kind of effects.
update
css
/* * overflow => don't scrollbar * visiblity => content hidden * background => black background */ .bodyextra{ overflow:hidden; visibility:none; background:#000; } js
jquery(function ($) { $(document).ready(function(){ $("div.container_16").first().hide(); $(".grid_16").first().hide(); $('body').removeclass('bodyextra'); $("div.container_16").first().fadein(2000); $(".grid_16").first().slidedown(4000); }); } the logic behind make page work buffer zone. hide elements want fade in, remove class body , fade in.
update 2013.09.01
i see answer still generating traffic , have admit, since initial answer in 2011, have addition make
html/css
<noscript> <style type="text/css"> .bodyextra{ overflow:auto !important; visibility:visibile !important; } </style> </noscript> this can done <link rel="stylesheet" type="text/css" href="no-js.css" /> tag.
idea behind fix disabled javascript issue described theazureshadow in comments.
Comments
Post a Comment