JavaScript基础 window.location

2018-03-04  本文已影响0人  0说

window.location对象 用于获得当前页面的地址 (URL),并把浏览器重定向到新的页面。返回的是对象

console.log( window.location )
图片.png

window.location.href 获取路径字符串

console.log( window.location.href )

http://localhost:63342/WWW/js%E8%AF%BE%E7%A8%8B/%E7%BB%83%E4%B9%A05.html?_ijt=qss9ig8in58oc351i49a0c876o

window.location.hash 返回的是链接后面#跟的内容

console.log( window.location.hash )
图片.png

window.location.search 链接后面?跟的内容

console.log( window.location.search )
图片.png
上一篇 下一篇

猜你喜欢

热点阅读