Javascript : Get current url

Hello friends, if you want to have the URL address of a page in JavaScript you can use the following function: window.location.href

Here is an example:

<html>
<head>
</head>
<body>	
	<script>
		var pageURL = window.location.href;
		console.log(pageURL)
    </script>
</body>
</html>


Explanations:

var pageURL = window.location.href : put the page URL in the variable.
console.log(pageURL) : display the URL.