Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Determining URL of current page

Posted on 2004-10-14
6
Medium Priority
?
226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
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…

715 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