Make sure to utilize the hash part of the URL, not the querystring. Anything following the # symbol is called the hash.
You can access the hash using document.location.hash and then parse that string accordingly.
var id = document.location.hash.split("/"); //convert the hash into an array by splitting at "/"
id = id.pop(); //retrieve the last item in the array
Although this method may seem simple and clear, it's risky to assume that the desired string will always be the final element in the array. To reduce chances of error, consider using a regular expression.
var hash = document.location.hash,
re = /\/new\/product\/(d+)/,
id = hash.match(re); //this matches both the entire string and the number for some reason
id = id.pop(); //to specifically retrieve the number again