Get current URL in JavaScript

Get the current URL in Web Browser in pure JavaScript.


Libraries

Code Snippet
document.URL  // Recommend

window.location.toString();
window.location.href
document.location.href
document.location.toString();


Implementation

Use one of the ways above to get the current URL. It's basically recommend to use <code>document.URL // returns https://vsnippets.com/snippet.php?s=57d97f8e8167d&t=Get%20current%20URL%20in%20JavaScript</code> See also: Redirect via JavaScript or jQuery (https://vsnippets.com/snippet.php?s=57d6eb10560fb&t=Redirect%20via%20JavaScript%20or%20jQuery)





Comments
  • mode_editWrite a comment



  • forumComments




Embed Code

We provide special containers which include the full snippet and a link to this site. So for example when you make a tutorial and you are using code from this site, you can use one of the following snippet embeddings:

Load Preview Get Code Close Preview







    Share
    Rating
    thumb_up 1 thumb_down
    Author
    Thorolus

    I'm the head developer and co-founder of GlovilGames Studios (glovilgames.com) and other platforms GlovilGames created, like vsnippets.com, worth-calculator.net, python-obfuscator.com and some mobile apps and games.

    Tags
    URL
    URI
    Web Browser



    Informations

    posted on 2016-09-14 18:49:18

    viewed 44 times

    snippet's UUID is 57d97f8e8167d

    Similar Snippets