• Monday , 30 May 2016
How to get current url in JavaScript and jQuery ?

How to get current url in JavaScript and jQuery ?

The window.location read-only property returns a Location object with information about the current location of the document.

we see all the property by this below Url

first  use window.location then write following property like


Or if you have jQuery you can do it like this:


Related Posts

  • http://joomlasticdeveloper.blogspot.in RonakParmar

    Hi, thanks for the explanation, its realy very helpful to me and all other like me who are new in jquery.
    Your code is simple to implement and the output of your code is also helpful to understand the code and i can identify which code is solve my issue.
    Thanks agian.

    • maddyzonetech

      its our pleasure that it is helpful for you.

  • http://www.appacyber.net/ Herman Nz

    Good job, friend

    • http://www.maddyzone.com/ Maddyzone

      Thanks @herman_nz:disqus

  • SHAN


  • http://www.bloganalyzer.blogspot.com/ Bloganalyzer

    Thumbs UP..great share..
    but may be you should recheck that $(location).attr(‘pathname’) gives /index.php instead of index.php

    and just one question..is there any direct way to get http://www.test.com:8082/index.php instead of just adding $(location).attr(‘protocol’), $(location).attr(‘hostname’) and $(location).attr(‘pathname’) ?

    • marsbox


  • sanjay

    Good job, Awesome Friend