Getting full URL with jQuery including parameters after question mark?

user13286 picture user13286 · Feb 10, 2014 · Viewed 61.1k times · Source

I am trying to use jQuery to get the current full URL of a page. The URL of a page looks like this:

http://myurl.com/ebook?page=43

If I use window.location.pathname it only returns everything before the ? so I would just get

http://myurl.com/ebook

How can I get the entire URL?

Answer

Mehran Hatami picture Mehran Hatami · Feb 10, 2014

You have:

window.location.href

and also:

document.URL