To get the URL of a document, use the JavaScript URL property. You can try to run the following code to display full URL of a document with JavaScript −
Example
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
</head>
<body>
<script>
var str = document.URL;
document.write("URL: "+str);
</script>
</body>
</html>