HTML - DOM Document URL Property



HTML DOM document URL property is a read-only property which returns the complete URL of the document including the protocol like https:// .

Syntax

 document.URL; 

Return Value

It returns string value which represents the URL of the document.

Example of HTML DOM Document 'URL' Property

The following example returns the URL of the document.

 <!DOCTYPE html> <html lang="en"> <head> <title> HTML DOM document URL Property </title> </head> <body> <p> Click to get the URL of this document. </p> <button onclick="fun()"> Click me </button> <p id="type"></p> <script> function fun() { let x = document.URL; document.getElementById("type").innerHTML = x; } </script> </body> </html> 

Supported Browsers

Property Chrome Edge Firefox Safari Opera
URL Yes 1 Yes 12 Yes 1 Yes 1 Yes 3
html_dom.htm
Advertisements