在父框架(javascript)中打开iframe页面
Open iframe page in parent frame (javascript)
我确定知情人士有解决我面临的这个问题的方法吗?我有一个带有索引的网站.html其中包含一个 Iframe。在此iframe中,将显示网站的所有页面...首页.html..信息.html...联系方式.html..等。
我想要一个javascript函数,以便当您通过google站点地图打开Home.html时,它会显示在Index.html的父框架中。我目前在每个子页面的 head 部分中具有的功能是:
<script>
if (parent.location.href == self.location.href){
window.location.href = 'index.html'
}
</script>
虽然这有效,但它不会记住子页面并使用默认 iframe 页面打开索引页面......主页.html因为 iframe 是这样编码的:
<iframe id="iframe" src="home.html" allowTransparency="true" id="iframeID" name="iframeID" width="100" height="100" scrolling="no" frameborder="no">
</iframe>
有没有人解决这个问题,因为我到处搜索过?谢谢。
尝试使用查询字符串设置location.href
,即:
// .getAttribute so we don't get the absolute URL
var src = document.getElementById("iframe").getAttribute("src");
if (parent.location.href === self.location.href)
location.href = "index.html?" + escape(src);
在索引中.html创建查询字符串检查并相应地设置 iframe 源:
if (location.search)
document.getElementById("iframe").src =
unescape(location.search.substring(1));
相关文章:
- 停止iframe页面中的所有动画
- 如何解析嵌入的iFrame以仅显示iFrame页面中的片段
- 从 iframe 页面事件更改父级的 css
- 在父框架(javascript)中打开iframe页面
- 重新加载父阴影框 iframe 页面,而不会丢失 POST 数据
- 实时检测 iframe 页面加载
- iFrame 页面过渡的 Javascript 控制
- 保留 iframe 页面的状态
- 当使用http访问我的facebook iframe页面时,我如何才能获得Modal而不是弹出窗口
- Jquery将一些上下文附加到特定的iframe页面
- 检查iframe页面是否包含使用JavaScript或jQuery的内容
- 如何在iframe中欺骗一个iframe页面加载非
- 如何防止iframe页面重定向父页面
- 如果iframe页面使用_parent target,请在新选项卡中打开iframe
- 检查iFrame页面是否存在
- 在iframe中加载网页,但替换iframe页面中url的一部分
- 如何将正确的URL传递到iframe页面
- Javascript /jquery:检测iframe页面加载失败
- 通过Javascript在各种浏览器窗口/选项卡中维护iFrame页面的状态
- Javascript,改变整个iframe页面