How can you check for a #hash in a URL using JavaScript? September 6, 2022 by Tarik Simple use of location hash: if(window.location.hash) { // Fragment exists } else { // Fragment doesn't exist }