在父Html页面上的Iframe中显示另一个html页面

时间:2015-11-22 06:16:16

标签: javascript html iframe

我有一个基本的html页面,我有一个div,点击哪个应该在同一个基本html页面上显示另一个html页面,在我插入的iframe中保存为display:none。

请帮忙!!!

the screenshots shows the div on which i am clicking and whole page should get replaced by another html page in an iframe

下面是基础html页面上的iframe和html,其中包含js函数,我试图实现这个...

        <iframe id='ifr'></iframe>
        <span id="previousemployment" onclick="previousemploymentIframe()">Previous Employment</span>

JS是

      function previousemploymentIframe() 
      {
         document.getElementById("ifr").src ='PreviousEmployment.html';
      }

1 个答案:

答案 0 :(得分:0)

查看此代码段并将代码应用到您自己的页面。根据我收集的内容,您使用跨度文本作为链接/按钮?

&#13;
&#13;
function prevEmpIframe() {
  var ifr = document.getElementById("ifr");
  ifr.src = 'PreviousEmployment.html';
}

//Crossbrowser Access of Iframe from Parent Page

var doc = iframe.contentDocument ? iframe.contentDocument : 
(iframe.contentWindow ? iframe.contentWindow.document : iframe.document);
&#13;
#prevEmp.show {
  display: block;
}
#prevEmp.hide {
  display: none;
}
#prevEmp { cursor: pointer; }
&#13;
<!doctype html>
<html>

<head>
  <base href="/" target="_self">
  <meta charset="utf-8">
  <style>
  </style>
</head>

<body>
  <section>
    <span id="prevEmp" onclick="prevEmpIframe()">Previous Employment
          <iframe id='ifr' src="/"></iframe>
      </span>
  </section>
  <script>
  </script>
</body>

</html>
&#13;
&#13;
&#13;