4

Possible Duplicate:
Request Address in Javascript

Is there any method to retrieve the URL of the current page in JavaScript or jquery?

Please help.

Community
  • 1
  • 1
jagrti
  • 55
  • 1
  • 1
  • 2

4 Answers4

2

window.location.href

Here is how you would do it in jQuery :P

(function($) {
   $.getUrl = function() {
       return window.location.href;
   }
})(jQuery);

jsFiddle.

Warning: Obviously the jQuery function is for LOLs. Don't really use it.

alex
  • 479,566
  • 201
  • 878
  • 984
0

Yes, use location.href

alert(location.href)
Edgar Villegas Alvarado
  • 18,204
  • 2
  • 42
  • 61
0

Use the following

document.location.href

Ammu
  • 5,067
  • 9
  • 34
  • 34
0

Use the

document.location.href
CloudyMarble
  • 36,908
  • 70
  • 97
  • 130