// 前画面に遷移する or 2つ前に遷移する function historyBack(){ var url = location.href; if(url.match(/historyBack/)){ history.go(-2); }else { history.back(); } }