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.

1
  • Please choose suitable titles for your question. Commented Aug 16, 2012 at 6:38

4 Answers 4

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.

Sign up to request clarification or add additional context in comments.

2 Comments

@Blender I added some :)
made an overkill jQuery solution: $.getUrl(). That code inits the function.
0

Yes, use location.href

alert(location.href)

Comments

0

Use the following

document.location.href

Comments

0

Use the

document.location.href

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.