function getURL() {
alert("The URL of this page is: " + window.location.href);
}
// this gives you just the URL without params
var currentUrlWithoutParams = window.location.href.split("?")[0];
document.URL
> "http://example.com/page1.html"
document.location.href
> "http://example.com/page1.html"
location.protocol
location.hostname
location.pathname
location.hash
location.href