function goBack() { var r = document.referrer; if (r.match('yandex') || r.match('google')) { window.location = '/'; return; } window.history.back(); }