Skip to content

Instantly share code, notes, and snippets.

@bign8
Last active August 29, 2015 14:05
Show Gist options
  • Save bign8/a1b2598e7ea5d05f20ea to your computer and use it in GitHub Desktop.
Save bign8/a1b2598e7ea5d05f20ea to your computer and use it in GitHub Desktop.
Timeout redirect (js)
! function(t, i, m, e, r, s) {
var a = t.getElementById(i),
c = function() {
a.innerHTML = r, t.location = e
},
d = function() {
a.innerHTML = s.replace('{x}', m).replace('{s}', 1 == m-- ? '' : 's');
setTimeout(0 >= m ? c : d, 1e3)
};
t.addEventListener('DOMContentLoaded', d);
}(document, 'counter', 10, '/', 'now', 'in {x} second{s}');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment