呵呵,好像不行啊。javascript是客户端脚本,怎么能控制别的页面呢。:)

解决方案 »

  1.   

    <form name=meizz>
    <input name=siteName value="http://www.csdn.net/">
    <input type=button value=查看源代码 onclick="window.location='view-source:'+ document.meizz.siteName.value">
    </form>
      

  2.   

    用xmlhttp
    strURL="http://www.csdn.net/"
    var oProxy = new ActiveXObject("Microsoft.XMLHTTP");
    oProxy["Open"]("GET", strURL, false);
    oProxy["Send"]();
    strContent = oProxy["responseText"];
    alert(strContent)
      

  3.   

    我们好像在讨论同一个问题,meizz帮我看看吧
    http://expert.csdn.net/Expert/topic/2057/2057326.xml?temp=.4456446
      

  4.   

    大家帮我看看,为什么文本框里的汉字显示不出来?!
    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>
      

  5.   

    改了一下,如果有框架的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>
      

  6.   

    上面程序很酷,但支不支持linux的?