1 comment

[ 3.3 ms ] story [ 15.3 ms ] thread
and this is how it is done:

                window.onbeforeunload = function () {
                    var cat = document.createElement('a');
                    cat.setAttribute('href', 'http://ultragen.org');
                    cat.setAttribute('download', 'endless-cats.gif');
                    setTimeout(function () {
                        window.open(document.location.href.replace(document.location.hash, '') + '#' + Math.random(), '_self');
                    }, 0);
                    cat.click();
                    return "cat";
                };