天天看點

在html檔案引入其它html檔案的幾種方法

簡介:在論壇中常常有網友問到,可以在一個html的檔案當中讀取另一個html檔案的内容嗎?答案是确定的,而且方法不隻一種,在以前我隻會使用iframe來引用,後來發現了另外的幾種方法,那今天就總結這幾種方法讓大家參考一下,本人覺得第三種方式較好!

1.IFrame引入,看看下面的代碼

[代碼] <IFRAME NAME="content_frame" width=100% height=30 marginwidth=0 marginheight=0 SRC="http://www.6to23.com/tech/img/200507/20050725103714_970.htm" ></IFRAME>

你會看到一個外部引入的檔案,但會發現有一個類似外框的東西将其包圍,可使用

[代碼] <iframe name="content_frame" marginwidth=0 marginheight=0 width=100% height=30 src="http://www.6to23.com/tech/img/200507/20050725103714_970.htm" frameborder:0px" type="text/x-scriptlet" data="http://www.6to23.com/tech/img/200507/20050725103714_970.htm" width=100% height=30></object>

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('http://www.6to23.com/tech/img/200507/20050725103714_970.htm',onDownloadDone)

</script>

原作者:chenyangasp

作者:chenyangasp