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
  • 460,746
  • 196
  • 858
  • 974
0

Yes, use location.href

alert(location.href)
Edgar Villegas Alvarado
  • 17,924
  • 2
  • 41
  • 61
0

Use the following

document.location.href

Ammu
  • 4,837
  • 9
  • 32
  • 34
0

Use the

document.location.href
CloudyMarble
  • 36,156
  • 70
  • 93
  • 127