如果是要调用一个html文件,并得到其执行后的代码的话可以用以下脚本: Sub getOtherpage() url ="2.htm" ' 可以为任何其他网站的URL'
set http=createobject("Microsoft.XMLHTTP") http.open "POST",url,false '调用2.htm,提交方式为post' http.setrequestheader "Content-Type","application/x-www-form-urlencoded" http.send "username=test" '提交一个username信息给2.htm,其值为test' resbody = bytes2BSTR(http.responseBody) ' 获得2.htm的执行结果',反返回代码 document.all.div1.innerHTML=resbody end sub
是用VBScript写的,也可以用JavaScript来实现XMLHttp技术
其实就是一个html网页 当加载的时候调用另外一个 html文件
如果你是要用几个小页面来拼你的大页面的这种调用的话,可以用frame来实现.简单,传统,不容易出错
!--1.htm--> <html><head><title>页面1</title></head> <body> <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 sub callpage() dim xmlhttp,html set xmlhttp = createobject("microsoft.xmlhttp") xmlhttp.open "get", "2.htm", false xmlhttp.setrequestheader "content-type","text/xml" xmlhttp.send
html = bytes2bstr(xmlhttp.responsebody) document.write html end sub call callpage()</script> </body></html>
<!--2.htm ,任意,最好不要包括<html><head>..</head></body>之类的标记 把这两个文件的代码Copy试一试 --> <table><tr> <td><select size="1" name="Customerid" > <option selected>Please choose one book of yours</option> <option value="v1" label="l1">text1</option> <option value="v2" label="l2">text2</option> <option value="v3" label="l3">text3</option> </select><td> <td id="show">显示处</td> </tr></table>
Sub getOtherpage()
url ="2.htm" ' 可以为任何其他网站的URL'
set http=createobject("Microsoft.XMLHTTP")
http.open "POST",url,false '调用2.htm,提交方式为post'
http.setrequestheader "Content-Type","application/x-www-form-urlencoded" http.send "username=test" '提交一个username信息给2.htm,其值为test'
resbody = bytes2BSTR(http.responseBody) ' 获得2.htm的执行结果',反返回代码 document.all.div1.innerHTML=resbody
end sub
<html><head><title>页面1</title></head>
<body>
<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
sub callpage()
dim xmlhttp,html
set xmlhttp = createobject("microsoft.xmlhttp")
xmlhttp.open "get", "2.htm", false
xmlhttp.setrequestheader "content-type","text/xml"
xmlhttp.send
html = bytes2bstr(xmlhttp.responsebody)
document.write html
end sub
call callpage()</script>
</body></html>
把这两个文件的代码Copy试一试
-->
<table><tr>
<td><select size="1" name="Customerid" >
<option selected>Please choose one book of yours</option>
<option value="v1" label="l1">text1</option>
<option value="v2" label="l2">text2</option>
<option value="v3" label="l3">text3</option>
</select><td>
<td id="show">显示处</td>
</tr></table>