Javascript获得各种当前网页页面详细地址的实现

    技术2026-05-13  7

    很简单,自己留着看的。。。。

     

    设置或获取整个 URL 为字符串。<script>

    alert(window.location.href);</script>

     

    设置或获取 URL 的协议部分。<script>alert(window.location.protocol)</script>

     

    设置或获取 href 属性中跟在问号后面的部分。<script>alert(window.location.search)</script>

     

     

    设置或获取 location 或 URL 的 hostname 和 port 号码。<script>alert(window.location.host)</script>

    最新回复(0)