国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 網站 > WEB開發 > 正文

在html頁面中包含靜態或動態頁面方法

2024-04-27 14:59:06
字體:
來源:轉載
供稿:網友

1.可以用 download 行為下載后再用 innerHTML 特性顯示出來。
具體步驟:

<span id="demo" src="demo.htm"
style="behavior:url(#default#download)"></span>
<SCRipT>
function window.onload(){
demo.startDownload(demo.src,fnDownload)
}
function fnDownload(oSource){
demo.innerHTML=oSource
}
</SCRIPT>

被調用頁demo.htm的代碼。

<span style="color:red;font:bold 12px Tahoma">
測試 演示 TEST test DEMO demo</span>

注意:在本例中id為demo的對象必須設置它的默認行為為download。


2.script。需要注意的是include.js里不能再包含<script>和</script>,擴展名隨意,所有內容必須經由 write()、wirteln()、innerHTML、innerText、outerHTML或outerText 輸出顯示。代碼示例:

<script src="include.js"></script>

<script language="javaScript" src="http://www.newsccn.com/count.php?contentid={$contentid}"></script>

3.iframe。這個不用多解釋了,有疑問的話請第一部分第六章。代碼示例:

<iframe src="index.asp"></iframe>

4.Object(Scriptlets組件)。代碼示例:

有滾動條<br>
<object data="index.asp" type="text/html" width=400 height=300></object>
<br>無滾動條<br>
<object style="border: 0px" type="text/x-scriptlet" data="index.asp" width=400 Height=300></object>

5.SSI(服務器端包含)。代碼示例:

<!--#include file="index.html"-->
<!--#include virtual="/index.html"-->

6.Server.Transfer,Server.Execute(ASP對象的方法)。代碼示例:

server.execute ("index.asp")
server.transfer ("index.asp")

7.fso(FileSystemObject,文件讀寫組件)代碼示例:

<%
TF=Server.Mappath("index.asp")
set fs=server.createobject("scripting.filesystemobject")
set ts=fs.opentextfile(TF)
Do While(ts.atendofstream<>true)
response.write(ts.readline)
Loop
ts.close
%>

8.xmlHTTP組件。代碼示例:

<script for="window" event="onload">
with(new ActiveXObject("Microsoft.xmlhttp")){
open("get",demo.src,false,"","")
send()
demo.innerHTML=ResponseText
}
</script>
<span id="demo" src="demo.htm"></span>

需要注意,目標文件最好以Unicode或UTF-8編碼保存,否則目標文件中的雙字節文字會變成亂碼。當然,可以用下面的函數把返回的ResponseText處理一下,但是這樣效率比較低,文件較大時不推薦使用。XMLHTTP這種方法也可以在后臺程序中使用。

<script language=vbscript>
function bytes2bstr(vin)
strreturn = ""
for i = 1 to lenb(vin)
thischarcode = ascb(midb(vin,i,1))
if thischarcode < &h80 then
strreturn = strreturn & chr(thischarcode)
else
nextcharcode = ascb(midb(vin,i+1,1))
strreturn = strreturn & chr(clng(thischarcode) * &h100 + cint(nextcharcode))
i = i + 1
end if
next
bytes2bstr = strreturn
end function
</script>

9.HTC(HTML Component,將在下一章中介紹)。
(1)包含頁代碼。

<span style="behavior:url(index.htc)"></span>

(2)被包含頁index.htc的代碼。

<public:attach event="oncontentready" onevent="loadit()" />
<script>
function loadit(){
insertAdjacentHTML("afterBegin", include.innerHTML)
}
</script>
<xmp id="include">
被包含內容
<a href=http://www.Flash8.net>flash8</a>
</xmp>

特別提示
本例代碼運行效果如圖2.4.5所示,頁面中所顯示的文字為demo.htm頁的。

圖2.4.5 download行為應用效果

特別說明

download 行為的作用是下載文件并在下載完成后通知一個指定的回調函數,該行為只有一個startDownload方法:
startDownload 下載指定文件,該方法帶兩個參數,第一個參數為指定下載的文件地址,第二個參數為下載完成后要執行的代碼的函數的指針。如果調用的函數是用 VBScript 腳本編寫,需要使用 GetRef 函數獲取此回調函數的指針。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 龙陵县| 德清县| 弥渡县| 中西区| 古交市| 吉木乃县| 开原市| 越西县| 阿图什市| 株洲市| 津市市| 萝北县| 黑水县| 松潘县| 焦作市| 阳谷县| 青神县| 威远县| 合肥市| 阿克陶县| 措勤县| 安龙县| 周口市| 龙井市| 临汾市| 阳曲县| 金山区| 富平县| 雷州市| 香港| 桐城市| 祥云县| 周至县| 若羌县| 禄劝| 都江堰市| 临江市| 星座| 扬中市| 德令哈市| 海林市|