Determining URL of current page

How can I use JavaScript to determine the URL of the current HTML page (the page in which the script is running)?
vladc6Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
KupiConnect With a Mentor Commented:
If you need a function:

<script type="text/javascript">

function getPageLocation() {
  return window.location;
}

</script>

<body onload="var url = getPageLocation(); alert(url);">
0
 
KupiCommented:
Try:

var url = window.location;

:)
0
 
devicCommented:
location is an object
and string is location.href
0
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 
KupiCommented:
location Property
This property contains details of the current URL of the window and its value is always the Location object for that window.

Syntax: window.location

http://www.devguru.com/Technologies/ecmascript/quickref/window.html
0
 
devicCommented:
yes, and if we need the string, then is location.href
0
 
vladc6Author Commented:
Thanks everyone... window.location.href worked!
0
All Courses

From novice to tech pro — start learning today.