如何在html文件中包含其他html文件

1.IFrame
框架的形式.
<iframe name="toppage" width=100% height=30 marginwidth=0 marginheight=0 src="top.htm" ></iframe>
iframe也称作嵌入式框架,嵌入式框架和框架网页类似,它可以把一个网页的框架和内容嵌入在现有的网页中。它与<frame>不同的是,iframe可以嵌在网页中的任意部分。
属性:      name="..."定义的名字
         scr="..."定义显示的内容的来源
         frameborder="..."定义边界(0或1)
         margwidth="..."设置边界和其中内容之间的宽间距
         margheight="..."设置边界和其中内容之间的高间距
         align="..."控制对齐方式(left, center, right, justify)
         noresize="..."使帧的尺寸不能变
         scrolling="..."设置滚动条的表示方式(auto, yes, no)
         height="..."高度
         width="..."宽度
allowtransparency="true"是否允许透明
这种不用下载文件,可是透明背景总是不行,而且总是不能顶格对齐。郁闷。


2.<object>
<object type="text/x-scriptlet" data="top.htm" width=100% height=30></object>

<object id=editBox data="http://evil.2ec.cn/" width="100%" height=500 type=text/x-scriptlet>


3.Behavior的download方式
<span id=showImport></span>
<IE:Download ID="oDownload" STYLE="behavior:url(#default#download)" />
<script>
function onDownloadDone(downDate){
showImport.innerHTML=downDate
}
oDownload.startDownload('top.htm',onDownloadDone)
</script>
如果头和尾都用这个办法,那需要把ID改改。
<!--显示页面头-->
<span id=showImport1></span>
<IE:Download ID="oDownload1" STYLE="behavior:url(#default#download)" />
<script>
function onDownloadDone(downDate){
showImport1.innerHTML=downDate
}
oDownload1.startDownload('top.htm',onDownloadDone)
</script>
<!--页面头显示结束-->
<!--显示页面尾-->
<span id=showImport2></span>
<IE:Download ID="oDownload2" STYLE="behavior:url(#default#download)" />
<script>
function onDownloadDone(downDate){
showImport2.innerHTML=downDate
}
oDownload2.startDownload('bottom.htm',onDownloadDone)
</script>

<!--页面尾显示结束-->

这种显示的最好,可是需要下载文件,IE浏览器通常会自动拦截,如果不手动允许下载,那么包含的外部文件就不会显示。

4.<script>
就是把相关的html文件转化为js文件.再在调用的时候用
<script src="top.js"></script>
这个方法有一点要注意,用来包含象头部,导航这些的话,建议不要用这个.不利于搜索引擎的搜集。
原文地址:https://www.cnblogs.com/kuyuecs/p/1326847.html