window.location.href 和 window.open 的区别

Window.location.href="http://www.longeco.com.cn/

     这是JAVASCRIPT定位到另一个地址的语句,有点像WINDOW.OPEN区别是前者不打开新页面 。


WINDOW.OPEN例子为:

 

     window.open("http://www.longeco.com.cn/") ;

 

如果top信息不变,只改变中间的页面,用location.href方法。

   

     location.href="http://www.longeco.com.cn/"  ;

window.location.hrefwindow.opener.location.href都是用于获取或设置当前页面的URL。 window.location.href是获取或设置当前页面的URL。可以通过将一个新的URL赋值给window.location.href来导航到该URL。例如,可以使用window.location.href = "https://www.example.com"将当前页面导航到https://www.example.com。 window.opener.location.href是获取或设置打开当前页面的父页面的URL。它在使用window.open()方法打开一个新窗口后才有值。可以通过将一个新的URL赋值给window.opener.location.href来导航到父页面的URL。例如,可以使用window.opener.location.href = "https://www.parentpage.com"将父页面导航到https://www.parentpage.com。 需要注意的是,window.opener.location.href只能在通过window.open()方法打开新窗口中使用,而不能在同一窗口或不是通过window.open()方法打开的窗口中使用。而window.location.href可以在任何窗口中使用。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [window.location.href的用法(动态输出跳转)](https://blog.csdn.net/weixin_31690531/article/details/115238595)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值