I only want to have the numbers of my URL as return. At the moment I use:
alert(document.URL);
to get the whole URL. But is there any other easy solution to get only the ID-Numbers from my URL as result? I also use jQuery and PHP in this project.
I only want to have the numbers of my URL as return. At the moment I use:
alert(document.URL);
to get the whole URL. But is there any other easy solution to get only the ID-Numbers from my URL as result? I also use jQuery and PHP in this project.
var numbers = document.URL.match(/\d+/g) will return all numbers in a URL (eg for this thread) document.URL.match(/\d+/g) => ["19570840"]
alert(document.URL.match(/\d+/g));
Simple. I would put it in a fiddle, but uhh, jsFiddle doesn't have any numbers in their url, so.