怎么根据地址把指定网页的源文件显示在文本框中?
如题,
用javascript的view-source好像都要在新窗口显示,有没有办法把我们所要的某一个网站地址的源文件直接在文本框上显示出来呢
请各位高手帮忙,谢谢
------解决方案-------------------- <script language= "JavaScript " type= "text/javascript ">
<!--
function getXML()
{
oDiv = document.all.m
oDiv.innerHTML = "正在装载栏目数据,请稍侯....... "
oDiv.style.display= " "
xh = new ActiveXObject( "Microsoft.XMLHTTP ")
xh.onreadystatechange = getReady
xh.open( "GET ",a.value,true)
xh.send()
}
function getReady()
{
if(xh.readyState==4)
{
if(xh.status==200)
{
oDiv.innerHTML = "完成 "
document.all.txt.value=xh.responseText;
}
else
{
oDiv.innerHTML = "抱歉,装载数据失败。原因: " + xh.statusText
}
}
}
//-->
</script>
<input name=a value= "http://www.domain.com " style= "width:600px "> <br>
<textarea id= "txt " rows= "10 " cols= "100 "> </textarea> <br>
<div id=m> </div>
<input onclick= "getXML() " type= "button " value= "得到源代码 ">