I did a simple demo that revises in X for a few seconds and redirects the url job. If you do not want to wait for the count to finish, just click on the counter to redirect it without any time. A simple caunter that will count down during a ripple in the middle of the page. You can launch it onclick or while some page is loaded.
LIVE DEMO ONLOAD
LIVE DEMO ONCLICK
I also made a github repo for this: https://github.com/GlupiJas/redirect-counter-plugin
Sample JS code:
// FUNCTION CODE function gjCountAndRedirect(secounds, url) { $('#gj-counter-num').text(secounds); $('#gj-counter-box').show(); var interval = setInterval(function() { secounds = secounds - 1; $('#gj-counter-num').text(secounds); if(secounds == 0) { clearInterval(interval); window.location = url; $('#gj-counter-box').hide(); } }, 1000); $('#gj-counter-box').click(function() //comment it out -if you dont want to allo count skipping { clearInterval(interval); window.location = url; }); } // USE EXAMPLE $(document).ready(function() { //var var gjCountAndRedirectStatus = false; //prevent from seting multiple Interval //call $('h1').click(function(){ if(gjCountAndRedirectStatus == false) { gjCountAndRedirect(10, document.URL); gjCountAndRedirectStatus = true; } }); });
DevWL Jan 04 '16 at 4:19 2016-01-04 04:19
source share