Solved

Determining URL of current page

Posted on 2004-10-14
6
219 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
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
I was able to prove the index of the even , how can i get the even index? 4 29
jQuery Dialog Autoresize Bug 2 25
jQuery force form POST 7 55
Do alert on select 6 15
I've been trying to accomplish this for a while and it just struck me yesterday how to accomplish this task. I have done searches all over the internet looking for ways to email pages from my applications and finally I have done it!!! Every single s…
This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
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…

820 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