Skip to content

Instantly share code, notes, and snippets.

@panych
Created September 29, 2015 06:43

Revisions

  1. panych created this gist Sep 29, 2015.
    13 changes: 13 additions & 0 deletions funnyURL.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    function funnyURL(word, interval, prevID) {
    prevID = prevID ? prevID : this.prevID; // assume that undefined is OK
    clearInterval(prevID);

    var i = 0, ID;
    ID = setInterval(function() {
    history.replaceState(null, '', word.slice(0,i+1));
    i = i+1;
    if (i >= word.length) clearInterval(ID);
    }, interval);

    return this.prevID = ID;
    }