Gostaria de compartilhar com todos a dica abaixo: como obter a URL atual get url através de JavaScript.

Apesar de o código ser bem simples, ele é muito útil.

<html>
<body>

<p>A url completa da página atual é:</p>
<script>
document.write(document.URL);
</script>

</body>
</html>

OBS: Em alguns poucos browsers o código abaixo pode interpretar melhor mudanças 'Ajax' na URL, feitas com o uso de #.

document.write(window.location.href)

Outras variações:

document.write(window.location.protocol)
document.write(window.location.host)
document.write(window.location.pathname)

O código acima vai exibir:

"http"
"devmedia.com.br"
"artigos/index.html"

E claro, você também pode concatenar conforme abaixo:

var newURL =
  window.location.protocol + "//" +
  window.location.host + "/" +
  window.location.pathname;

Confira também