They are called "Hash." Say your link has an identifier, you can do it like this:
document.getElementById("link").hash;
This will give you a "#" anyway, but you can easily replace it:
document.getElementById("link").hash.replace("#","");
Good luck
source share