JS的window-location

    xiaoxiao2022-07-12  149

    href就是连接

    hostname就是域名

    pathname就是路径名

    protocol就是协议名

    assign跳转有回退

    replace跳转  忘了之前的了!

    window.location.href 返回当前页面的 href (URL) window.location.hostname 返回 web 主机的域名 window.location.pathname 返回当前页面的路径或文件名 window.location.protocol 返回使用的 web 协议(http: 或 https:) window.location.assign 加载新文档 window.open(): 是用来打开一个新窗口的函数 window.location.assign(url) : 加载URL 指定的新的 HTML 文档。就相当于一个链接,跳转到指定的url,当前页面会转为新页面内容,可以点击后退返回上一个页面。//跳转有回退 window.location.replace(url) : 通过加载 URL 指定的文档来替换当前文档 ,这个方法是替换当前窗口页面,前后两个页面共用一个窗口,所以是没有后退返回上一页的。//没有回退 location.search 查询条件!

     

    最新回复(0)