href 属性是一个可读可写的字符串,可设置或返回当前显示的文档的完整 URL。
因此,我们可以通过为该属性设置新的 URL,使浏览器读取并显示新的 URL 的内容。
</>code
- location.href=URL
假设当前的 URL 是: http://example.com:1234/test.htm#part2:
</>code
- <html>
- <body>
- <script type="text/javascript">
- document.write(
location.href
);- </script>
- </body>
- </html>
输出:
</>code
- http://example.com:1234/test.htm#part2
如对本文有疑问,请提交到交流论坛,广大热心网友会为你解答!! 点击进入论坛
Powered by 365建站网 RSS地图 HTML地图
copyright © 2013-2024 版权所有 鄂ICP备17013400号