You can use this code
var url = "http://www.mysite.com/#!/edit/2695"; var pieces = url.split("/#!/"); pieces = pieces[1].split("/"); // pieces[0] == "edit" // pieces[1] == "2695"
If you just need a number after editing, you can also use regex
var url = "http://www.mysite.com/#!/edit/2695"; var match = url.match(/#!\/edit\/(\d+)/); if (match) {
You can see how they work here: http://jsfiddle.net/jfriend00/4BTyH/
source share