One of my most popular answers on Stack Overflow has been about exactly these properties. This trick you are using is new to me and you've helped me improve the answer so it works for any URL. Thank you!
Updated answer here:
http://stackoverflow.com/questions/6944744/javascript-get-po...
I also created a JSFiddle to test here: