window.location.href的用法是什么?


本文摘自PHP中文网,作者青灯夜游,侵删。

window.location 对象可用于获取当前页面地址(URL)并把浏览器重定向到新页面。

window.location 对象可不带 window 前缀书写。

window.location.href

window.location.href 属性返回当前页面的 URL。

在js中,window.location.href经常用于页面跳转。它主要有如下几种用法:

1、在当前页面打开URL页面。

需要注意的是window.location.href=window.location.hrefwindow.location.reload()都是刷新当前页面。区别在于是否有提交数据。当有提交数据时,window.location.Reload()会提示是否提交,window.location.href=window.location.href;则是向指定的url提交数据

1

2

3

4

self.location.href="url"

location.href="url"

window.location.href="url"

this.location.href="url"

2、在父页面打开URL页面。

1

parent.location.href="url"

3、在顶层页面打开URL页面。

1

top.location.href="url"

推荐教程:js教程

以上就是window.location.href的用法是什么?的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

window.location.href的用法是什么?

更多相关阅读请进入《window.location.href》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...