var timeout = 11; // in seconds var msgContainer = $('<div />').appendTo('body'), msg = $('<span />').appendTo(msgContainer), dots = $('<span />').appendTo(msgContainer); var timeoutInterval = setInterval(function() { timeout--; msg.html('Redirecting in ' + timeout + ' seconds'); if (timeout == 0) { clearInterval(timeoutInterval); redirect(strUrl); } }, 1000); setInterval(function() { if (dots.html().length == 3) { dots.html(''); } dots.html(function(i, oldHtml) { return oldHtml += '.' }); }, 500);
Take a look at jsFiddle .
If you want to have a second thing, replace the corresponding line above ...
msg.html('Redirecting in ' + timeout + ' second' + ((timeout != 1) ? 's' : ''));
Of course, this works well with English, but probably with other languages, it may not be that simple.
source share