一、适用背景
页面A嵌入Iframe页面BIframe页面B跳转到页面C由于是在Iframe页面B中跳转到页面C,所以页面C是以Iframe形式显示。我想要页面C是以地址栏中是页面C的url的形式显示。 如图所示: 不做任何处理,直接由页面B跳转到页面C是这样: 但是,我想实现这样的效果:
二、实现
iframe页面B跳转到页面C之前先获取父页面的url,然后在父页面打开页面C。即页面C是页面A跳转过去的,而不是在 iframe页面B中跳转过去的。
parent
.location
.href
="/url" 在父页面打开新页面
三、window.location.href的用法
1.window
.location
.href
=window
.location
.href
; 刷新当前页面,向指定的url提交数据
window
.location
.Reload():刷新当前页面。window
.location
.Reload()会提示是否提交
2.self
.location
.href
="/url" 当前页面打开
URL页面
location
.href
="/url" 当前页面打开
URL页面
windows
.location
.href
="/url" 当前页面打开
URL页面,前面三个用法相同。
this.location
.href
="/url" 当前页面打开
URL页面
parent
.location
.href
="/url" 在父页面打开新页面
top
.location
.href
="/url" 在顶层页面打开新页面
这部分是参考别的博主博客记录下来的,忘记了博客链接,侵删。