music.html

跳转

  1. <input type="text" id="input">
  2. <script>
  3. var input=document.getElementById("input");
  4. input.onkeydown=function(event){
  5. if(event.keyCode==13){
  6. console.log(this.value);
  7. location.href=`search.html?s=${this.value}` //主要是这一段代码
  8. }
  9. }

search.html

传值

  1. <p>搜索</p>
  2. <script>
  3. console.log(location.search.split("=")[1])
  4. var keyword=location.search.split("=")[1];
  5. var c=decodeURIComponent(keyword);
  6. console.log(c);
  7. </body>
  8. </html>