2017-04-15 112 views
0

我是html新手。我嘗試了很多關於調整iframe的代碼。但是任何代碼都不適用於我的項目。我正在使用Dreamweaver和xhtml 1.0。我在我的索引網頁上包含了iframe(index.html)。現在我想在iframe中打開主頁(Home.html),Services.html等。 home.html和其他頁面會在iframe中打開,但iframe不會根據這些頁面的內容調整大小。如果有人知道,請給我一個工作代碼。根據內容自動調整iframe高度

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
 

 
<head> 
 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> 
 
<title>Pink Maid Beauty Salon | Home</title> 
 
</head><link rel="stylesheet" href="Style.css"> 
 
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> 
 
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" /> 
 
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script> 
 
<script type="text/javascript"> 
 
var MenuBar1 = new Spry.Widget.MenuBar("navigationbar", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"}); 
 
</script> 
 

 
<body> 
 

 
<!--Background--> 
 
<div class="body"> 
 

 
<!--Header--> 
 
<div id="header"></div> 
 

 
<!--Logo--> 
 
<div id="logo"></div> 
 

 
<!--Menu--> 
 
<div id="menu"> 
 
    <ul> 
 
    <li> 
 
     <h2><a href="#home">Sign Up <i class="fa fa-user-plus" aria-hidden="true"></i></a></h2> 
 
    </li> 
 
    <li> 
 
     <h2><a href="#news">Login <i class="fa fa-sign-in" aria-hidden="true"></i></a></h2> 
 
    </li> 
 
    <li> 
 
     <h2><a href="#contact">Cart <i class="fa fa-shopping-cart" aria-hidden="true"></i></a></h2> 
 
    </li> 
 
    </ul> 
 
</div> 
 

 
<!--Navigation--> 
 
<div id="navigation"> 
 
    <ul id="navigationbar" class="MenuBarHorizontal"> 
 
    <li><a href="Home.html" target="content">Home</a></li> 
 
    <li><a href="Services.html" target="content">Services</a></li> 
 
    <li><a href="Gallery.html" target="content">Gallery</a></li> 
 
    <li><a href="About Us.html" target="content">About Us</a></li> 
 
    <li><a href="Contact Us.html" target="content">Contact Us</a></li> 
 
    </ul> 
 
</div> 
 

 
<!--Content--> 
 
<iframe src="Home.html" name="content" frameborder="0"> 
 
</iframe> 
 

 
</body> 
 
</html>

+0

不要使用spry它已被Adobe放棄多年。使用jQuery它不會很快。 – zer00ne

回答

0

這不是一樣簡單,因爲它應該是問題。我寫了一個js庫來解決這個問題,你可能會覺得有用。

https://github.com/davidjbradshaw/iframe-resizer

+0

請解釋一下如何使用這些js庫。 @David Bradshaw –

+0

https://github.com/davidjbradshaw/iframe-resizer#typical-setup然後將iframeResizer.contentWindow.min.js添加到iFrame中的頁面。 –

+0

這不是工作的先生。我不知道該怎麼辦。 –

相關問題