jquery - How I open in one link a circle loader 4sec and after that a new page? -
i want click in button next , happend 2 things: 1) show circle loader 4sec in middle of screen , after 2) show new page in same tab. can't handle it. tried code of course it's not running. maybe needs jquery, don't know.
my html is:
<a href="#modalloader (for 4 sec)" href="new_page.html (in same tab after 4sec)" class="btn"> next <i class="fa fa-arrow-right"></i> </a> <div id="modalloader"> <div class="loader-block"> <div class="loader"></div> <div class="stop">stop</div> </div> </div> my css is:
.modalloader{ display: none; position: fixed; z-index: 1; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4); } .loader-block{ position: fixed; top: 50%; left: 50%; margin-top: -90px; margin-left: -100px; } .loader { border-radius: 50%; border-top: 4px solid #2d4371; border-bottom: 4px solid #2d4371; border-right:4px solid #2d4371; border-left:4px solid #9a9999; width: 170px; height: 170px; animation: spin 3s linear infinite; } .stop{ position: absolute; top: 30%; left: 45px; width: 100%; font-size: 50px; color: #2d4371; font-weight: bold; text-shadow: 3px 2px #506184; } @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } any idea fellows!!??
you can achieve way :
create div contain circle loader , give id (i'll use circle_lodr in example) , set div's z-index negative value in css (negative values aren't accepted z-index therefore won't displayed on page until change z-index's value ourself later on). set opacityto 0 in css.
now we'll add bit of javascript (remember you'll need jquery this) :
$(/*insert jq selector button activates thingie*/).click(function(){ var $loader = $("#circle_lodr"/*your div*/); $loader.css("zindex",999);/*any value put on top*/ /*trigger circular loading animation here*/ $loader.animate({ opacity: 1 },{ duration:/*some duration in ms, recommend 500*/, queue:false;/*usual settings ;)*/ }); settimeout(function(){ document.location.href="";/*replace empty string string containing url*/ }, 4000);/*4000ms <=> 4s, wait 4s before switching page, used document.location.href because wanted stay on same page, if not read window.open()*/ }); you need put bit of js in $(document).ready(); (just replace /*the func*/ js code above) :
$(document).ready(function(){ /*the func*/ }); and there have it.
Comments
Post a Comment