温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

window.location.href的作用有哪些

发布时间:2020-04-24 09:44:08 来源:亿速云 阅读:1657 作者:小新 栏目:web开发

今天小编给大家分享的是window.location.href的作用有哪些,相信很多人都不太了解,为了让大家更加了解window.location.href的作用,所以给大家总结了以下内容,一起往下看吧。一定会有所收获的哦。

window.location.href的作用有哪些

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提交数据

self.location.href="url"
location.href="url"
window.location.href="url"
this.location.href="url"

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

parent.location.href="url"

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

top.location.href="url"

以上就是window.location.href的作用有哪些的简略介绍,当然详细使用上面的不同还得要大家自己使用过才领会。如果想了解更多,欢迎关注亿速云行业资讯频道哦!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI