Browse - Programming Tips - How can I get the current URL?

Date: 2009dec28
Level: beginner
Language: javaScript
Platform: web

Q.  How can I get the current URL?

A.  Access the href member of the location object like this:

function displayCurrentUrl() { alert('Current URL is ' + location.href); }