How to get the URL for current document in Javascript

Document URL

document.URL property returns the URL of the current document. This is the URL that the browser used to load the document.

Example


<!DOCTYPE HTML> 
<html> 
    <body> 
        <script> 
            document.writeln(document.URL); 
        </script> 
    </body> 
</html><!-- ww w  . ja  v a2 s .  c o m-->

Click to view the demo





















Home »
  Javascript »
    Javascript Reference »




Array
Canvas Context
CSSStyleDeclaration
CSSStyleSheet
Date
Document
Event
Global
History
HTMLElement
Input Element
Location
Math
Number
String
Window