改了一下,如果有框架的URL你可以自己试试,有问题帖出来<form name=meizz> <input name=siteName value="http://www.csdn.net/"> <input type=button value=查看源代码 onclick="window.location='view-source:'+ document.meizz.siteName.value;viewsrc()"> <textarea name=text1 style="width: 90%; height: 50%"></textarea> </form><script> function viewsrc() { document.meizz.text1.value=bytes2bstr(loadContent(document.meizz.siteName.value)) } function loadContent(strURL) //I get this code from a friend (used for "function f_text3()") { var strContent = ""; if (typeof strURL != "string" || strURL == "")return strContent; try { var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
oProxy["Open"]("GET", strURL, false); oProxy["Send"](); /// strContent = oProxy["responseText"]; //get Text html strContent = oProxy["responseBody"]; //get Bin html, and then change2text } catch(e){status = e.description} return strContent; } function bytes2bstr(vin) //Have this code from a friend (used for "function f_text3()") { var st = new ActiveXObject("adodb.stream") with (st){ Type = 2 //var adTypeBinary = 1; var adTypeText = 2 Open() WriteText(vin) Position = 0 Charset = "GB2312" Position = 2 return ReadText } } </script>
<input name=siteName value="http://www.csdn.net/">
<input type=button value=查看源代码 onclick="window.location='view-source:'+ document.meizz.siteName.value">
</form>
strURL="http://www.csdn.net/"
var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
oProxy["Open"]("GET", strURL, false);
oProxy["Send"]();
strContent = oProxy["responseText"];
alert(strContent)
http://expert.csdn.net/Expert/topic/2057/2057326.xml?temp=.4456446
http://expert.csdn.net/Expert/topic/2057/2057326.xml?temp=.4456446
这里100分,楼主知道了一定要告诉我啊^-^<form name=meizz>
<input name=siteName value="http://www.csdn.net/">
<input type=button value=查看源代码 onclick="window.location='view-source:'+ document.meizz.siteName.value;viewsrc()">
<textarea name=text1 style="width: 90%; height: 50%"></textarea>
</form><script>
function viewsrc()
{
document.meizz.text1.value=loadContent(document.meizz.siteName.value)
}
function loadContent(strURL) //I get this code from a friend (used for "function f_text3()")
{
var strContent = "";
if (typeof strURL != "string" || strURL == "")return strContent;
try
{
var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
oProxy["Open"]("GET", strURL, false);
oProxy["Send"]();
strContent = oProxy["responseText"];
}
catch(e){status = e.description}
return strContent;
}
</script>
<input name=siteName value="http://www.csdn.net/">
<input type=button value=查看源代码 onclick="window.location='view-source:'+ document.meizz.siteName.value;viewsrc()">
<textarea name=text1 style="width: 90%; height: 50%"></textarea>
</form><script>
function viewsrc()
{
document.meizz.text1.value=bytes2bstr(loadContent(document.meizz.siteName.value))
}
function loadContent(strURL) //I get this code from a friend (used for "function f_text3()")
{
var strContent = "";
if (typeof strURL != "string" || strURL == "")return strContent;
try
{
var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
oProxy["Open"]("GET", strURL, false);
oProxy["Send"]();
/// strContent = oProxy["responseText"]; //get Text html
strContent = oProxy["responseBody"]; //get Bin html, and then change2text
}
catch(e){status = e.description}
return strContent;
}
function bytes2bstr(vin) //Have this code from a friend (used for "function f_text3()")
{
var st = new ActiveXObject("adodb.stream")
with (st){
Type = 2 //var adTypeBinary = 1; var adTypeText = 2
Open()
WriteText(vin)
Position = 0
Charset = "GB2312"
Position = 2
return ReadText
}
}
</script>