window.location.hash

来源:互联网 发布:网络被动攻击 编辑:程序博客网 时间:2024/06/07 13:15
<!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title></title>  </head>  <body>    <h1>子页面</h1>    <div></div>    <script type="text/javascript">    window.onload = function () {      var parentWindow = window.parent;      //监听自身hash的改变      window.onhashchange = function(event){        document.querySelector('div').innerHTML = window.location.hash;          }    };    </script>  </body></html>02.html <!DOCTYPE html><html>  <head>    <meta charset="utf-8">    <title></title>  </head>  <body>    <h1>子页面</h1>    <div></div>    <script type="text/javascript">    window.onload = function () {      var parentWindow = window.parent;      //监听自身hash的改变      window.onhashchange = function(event){        document.querySelector('div').innerHTML = window.location.hash;          }    };    </script>  </body></html>