var fin_link = decodeURIComponent(getURLParameter('p1')); var links = document.getElementsByClassName('finlink'); for (var i = 0; i < links.length; i++) links[i].setAttribute("href", fin_link); for (var j = 0; j < links.length; j++) { links[j].addEventListener('click', function (evt) { prelandAction(evt); window.removeEventListener('beforeunload', befUnlFunc); window.onbeforeunload = null; }); } function getURLParameter(name) { return decodeURIComponent( (RegExp(name + '=' + '(.+?)(&|$)').exec(location.search) || [, null])[1] || '' ); } //Autoredirect setTimeout(function () { window.onbeforeunload = null; window.location.href = fin_link; }, 60000 * 2); //Historyback ! function () { var t; try { for (t = 0; 10 > t; ++t) history.pushState({}, "", ""); onpopstate = function (t) { window.onbeforeunload = null; t.state && location.replace(fin_link); }; } catch (o) { } }();