<!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>
window.location.hash
最新推荐文章于 2024-06-04 22:28:38 发布