2017-05-30 28 views
0

說我有類似如下:錨鏈接到一節中的iframe內容

<!-- index.html --> 
<a href="#heading32">Link to Section</a> 

<section id="heading1">Section Name</section> 
<div>Content</div> 
<section id="heading2">Section Name</section> 
<div>Content</div> 
<section id="heading3">Section Name</section> 
<div>Content</div> 
<!-- More sections --> 
<section id="heading32">Section Name</section> 
<div>Content</div> 
<!-- More sections --> 

基本上,我想要實現類似於您在像維基百科,在那裏你點擊一個鏈接的網站找到什麼功能在內容列表中,它會將您的頁面向下滾動到鏈接的部分。

現在,我需要改變代碼如下:

<!-- index.html --> 
<a href="#heading32">Link to Section in iFrame</a> 
<iframe src="content.html"> 

<!-- content.html --> 
<section id="heading1">Section Name</section> 
<div>Content</div> 
<section id="heading2">Section Name</section> 
<div>Content</div> 
<section id="heading3">Section Name</section> 
<div>Content</div> 
<!-- More sections --> 
<section id="heading32">Section Name</section> 
<div>Content</div> 
<!-- More sections --> 

基本上,表的內容現在是在父容器,並點擊一個應有的iframe中的內容去鏈接的部分 - 與以前相同的功能,只是內容現在被重新定位。

我應該如何進一步修改我的實現來實現它?內容是從Microsoft Word文檔導出的,因此內容HTML文檔本身無法修改。然而,我的系統的框架確實允許我添加腳本和樣式表,但僅此而已。

回答

0

認爲這個問題的一個變種已被問及在另一個stackoverflow問題的答案。 open link in iframe

http://jsfiddle.net/HnXFj/2/

基本上這:

<a href="content.html" target="myIframe" >Link to Section in iFrame</a> 
<iframe src="content.html" name = "myIframe">