Solved

Determining URL of current page

Posted on 2004-10-14
6
214 Views
Last Modified: 2009-12-16
How can I use JavaScript to determine the URL of the current HTML page (the page in which the script is running)?
0
Comment
Question by:vladc6
  • 3
  • 2
6 Comments
 
LVL 3

Expert Comment

by:Kupi
ID: 12310839
Try:

var url = window.location;

:)
0
 
LVL 3

Accepted Solution

by:
Kupi earned 250 total points
ID: 12310863
If you need a function:

<script type="text/javascript">

function getPageLocation() {
  return window.location;
}

</script>

<body onload="var url = getPageLocation(); alert(url);">
0
 
LVL 25

Expert Comment

by:devic
ID: 12312580
location is an object
and string is location.href
0
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
LVL 3

Expert Comment

by:Kupi
ID: 12312675
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
 
LVL 25

Expert Comment

by:devic
ID: 12312733
yes, and if we need the string, then is location.href
0
 

Author Comment

by:vladc6
ID: 12314307
Thanks everyone... window.location.href worked!
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question