Answer: Use the
You can simply use the location property of a window (i.e.
window.location) to check whether a URL contain hash (
Let's take a look at the following example to understand how it basically works:
ExampleTry this code »
alert("Fragment component exists");
alert("Fragment component doesn't exist");
Here are some more FAQ related to this topic: