Get current URL with JavaScript?

0 votes
54 views
asked Nov 28, 2013 in java script by javics

How do I get the website URL?

Not the URL as taken from a link. On the loading page, I want to get the full, current URL of the current web page and store its value in a variable.

1 Answer

0 votes
answered Nov 28, 2013 by admin (8,115 points)

Use:

alert(document.URL);

See URL of type DOMString, readonly.

...