Location 对象包含有关当前 URL 的信息。
Location 对象是 Window 对象的一个部分,可通过 window.location 属性来访问。
Location 对象属性
location.hash
功能:返回URL中的hash(#号后跟0或多个字符),如果不包含则返回空字符串
location.host
location.href=”” 跳转页面
<button id="btn">跳转到百度</button><script>var btn = document.getElementById("btn");btn.onclick = function(){location.href="http://www.baidu.com"}</script>
页面跳转传值
01music
<input type="text" id="input"><script>var input = document.getElementById("input");input.onkeyup = function(event){if(event.keyCode == 13){console.log(this.value);location.href = `02search.html?s=${this.value}`}}</script>
02search
<p>搜索</p><script>console.log((location.search));console.log((location.search).split("=")[1]);var keyword = location.search.split("=")[1];var c = decodeURIComponent(keyword);console.log(c);</script>
