Solved

Determining URL of current page

Posted on 2004-10-14
6
209 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
Comment Utility
Try:

var url = window.location;

:)
0
 
LVL 3

Accepted Solution

by:
Kupi earned 250 total points
Comment Utility
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
Comment Utility
location is an object
and string is location.href
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 3

Expert Comment

by:Kupi
Comment Utility
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
Comment Utility
yes, and if we need the string, then is location.href
0
 

Author Comment

by:vladc6
Comment Utility
Thanks everyone... window.location.href worked!
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

763 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

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now