关于包含调用文件的几种方法
7.download Behavior<SCRIPT>
function oBehavior(url){
with(event.srcElement){
addBehavior('#default#download')
startDownload(url,oDownload)
}} function oDownload(oSource){
viewfield.innerHTML=oSource
}
</SCRIPT>
<button onClick=oBehavior("index.asp")>index.asp</button>
<span id="viewfield">内容暂缺</span>8.XMLHTTP
<script>
function getit(url){
with(new ActiveXObject("Microsoft.XMLHTTP")){
open("get",url,false,"","")
send()
viewfield.innerHTML=ResponseText
}
}
</script>
<button onClick=getit("index.asp")>index.asp</button>
<span id="viewfield">内容暂缺</span>
XMLHTTP方式需要注意,目标文件最好保存编码为Unicode或者UTF-8,否则会出现乱码。当然,还有解决的方法,用下面的函数把返回的ResponseText处理一下,只是这样效率比较低,文件较大时不推荐使用。 <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>
另外,XMLHTTP这种方法也可以在后台程序中用,不过要作相应修改9.HTC包含页代码:
<span style="behavior:url(index.htc)"></span>被包含页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>
1 2
特别说明:由于各方面情况的不断调整与变化,教育人生网所提供的所有考试信息仅供参考,敬请考生以权威部门公布的正式信息为准。