JavaScript проверка для хэша в URL

if (location.href.indexOf("#") != -1) {
    //current url has a #hash in it
}
Grepper