1window.location.protocol = “http:”
2window.location.host = “css-tricks.com”
3window.location.pathname = “/example/index.html”
4window.location.search = “?s=flexbox”const
5postID = (new URLSearchParams(window.location.search)).get('post');
6
1<!DOCTYPE html>
2<html>
3<body>
4
5<h2>JavaScript</h2>
6
7<h3>The window.location object</h3>
8
9<p id="demo"></p>
10
11<script>
12document.getElementById("demo").innerHTML =
13"The full URL of this page is:<br>" + window.location.href;
14</script>
15
16</body>
17</html>
18