2016-09-21 85 views
0

我是新的HTML iframes。点击浏览器后退按钮加载两个iframe

我的HTML代码如下所示。

index.html

<html> 
<head> 
    <script type="text/javascript"> 
     function change(content,content2) { 

      top.iframe_b.location.href = content2; 
      top.iframe_a.location.href = content; 

     }  
    </script> 

</head> 
<body> 
    <div class="container"> 

     <a title="" href="#" onclick="change('a.html','b.html')"><div class="smallbox">Click meee</div></a> 

     <div style="width: 30%; height: 100%; float:left"> 
      <iframe id="iframe_a" src="home.html" height="100%" width="100%" name="iframe_a"></iframe> 
     </div> 

     <div style="width: 70%; height: 100%; float:right"> 
      <iframe id="iframe_b" src="dash.html" height="100%" width="100%" name="iframe_b" style="border-left: solid; border-left-color: black"></iframe> 
     </div> 
    </div> 
</body> 

当我在链接Click meee点击则两个I帧iframe_aiframe_b将分别呈现a.htmlb.html页这是罚款。

但是,当我点击浏览器的后退按钮,那么它只改变iframe_a加载home.html。但iframe_b没有变化。 (广告最后更改href在javascript代码中为iframe_a

然后在第二次点击时,它将更改iframe_b并将其加载到dash.html中。

我希望iframes只有一次点击浏览器的后退按钮才能切换到最后一页。

如果可能或任何其他解决方案也将不胜感激,请就此建议。

回答

0

你真的需要iframe吗? 如果你想加载一些内容到主html页面,你可以用例如jQuery.load()功能。 (从服务器加载数据并将返回的HTML放入匹配的元素中)。

+0

我可以通过点击浏览器的后退按钮加载最后一页吗?我不认为它可能与那个 – AmanS

+0

jquery load()异步工作,所以你的index.html甚至不改变你的位置,但正如我前面提到,如果你想做任何改变,你可以通过使用一些JS代码来实现这一点。如果您希望在操作后显示/隐藏某些内容,例如点击,您可以通过多种方式进行操作。 – 3squad

相关问题