Javascript quick tip – returning urls

A few quick Javascript tips for you.  If you want to return or store the value of the current url of your page, try this:-


This will give you the entire url that is displayed in the address bar.


If you have a url containing a hash value (ie and want to return the hash, then use this:-



Want just the top-level domain name (eg  Give this a whirl:-


Leave a Reply

Your email address will not be published. Required fields are marked *