ページ名の取得
let path = location.pathname; // 現在のURLのパス部分(例: /foo/bar/index.html)を取得
let str = path.split('/'); // パスを「/」で分割し、配列にする(例: ["", "foo", "bar", "index.html"])
let page = str.slice(-1)[0]; // 配列の最後の要素(例: "index.html")を取得
if(page == ""){
page = str[str.length - 2]; // 配列の一つ前の要素を取得
}
console.log(page);
//ページ名が取得できない場合はディレクトリページ名で分岐
if(page == 'mail.php'){
//したい処理
}

