Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Request address in JavaScript [duplicate]

Tags:

javascript

Possible Duplicate:
Get current URL with JavaScript?

How do you get the address of the page you are on in JavaScript?

For example, if I had a script at somesite.com/javascript/home.html and I want to find out the request address (somesite.com/javascript/home.html), how do I get this information in JavaScript?

like image 826
LB. Avatar asked Jun 22 '09 21:06

LB.


1 Answers

You need to use: document.location or window.location

You can read more here. Or there is a little more explanation over there.

For clarifying matter:

Originally Posted by Mozilla Developer Center

document.location was originally a read-only property, although Gecko browsers allow you to assign to it as well. For cross-browser safety, use window.location instead.

like image 186
Artem Barger Avatar answered Sep 16 '22 17:09

Artem Barger