alert(document.documentElement.innerHTML)

解决方案 »

  1.   

    这个还是没有办法获得
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    和</html>
    还有没有其它的办法可以获得完整的HTML代码
      

  2.   

    <input type="button" value="查看源文件" onclick= 'window.location = "view-source:" +
    window.location.href'>
      

  3.   

    如果只是要查看当前页面那就是:
    // chouchy(到处流浪) 
    <input type="button" value="查看源文件" onclick= 'window.location = "view-source:" +
    window.location.href'>
      

  4.   

    <script language="JavaScript">
    function onDownloadDone(data) { 
    alert(data); 

    </script>
    <input type="button" id="behaviorID" style="behavior:url(#default#download)" value="获取完整的HTML代码" onclick=this.startDownload("test.htm",onDownloadDone)>
    -----------------
    注:test.htm为要获取代码的文件。
      

  5.   

    首先说明一点:outerHTML方法是不可靠的,因为他是一个可读写的属性,如果在查看之前源文件被方法
    object.outerHTML[ = outerHTML]
    或者
    object.innerHTML[ = innerHTML]
    修改了,得到的将是被修改后的,将与通过“查看源文件”所看到的并不一致。正确的方法是 tigerwen01(小虎)(编程艺术化) 所提供的。
    以下代码取得当前网页完整的HTML代码,跟用“查看源文件”所看到的是一致的。<script language="JavaScript">
    function getFileName()
    {
    var url=window.location.href;
    var pos=url.lastIndexOf("\\");//如果是网上文件,路径分割符为"\"
    if (pos==-1)   //pos==-1表示为本地文件
    pos=url.lastIndexOf("/"); //本地文件路径分割符为"/"
    var fileName=url.substring(pos+1); //从url中获得文件名
    return fileName;
    }function onDownloadDone(fileName)
    {
    alert(fileName); 

    </script>
    <input type="button" id="behaviorID" style="behavior:url(#default#download)" value="获取完整的HTML代码" onclick=this.startDownload(getFile(),onDownloadDone)>
      

  6.   

    查看完整HTML的办法
    1、建立一个名为“FullSource.html”的文件
    内容如下:
    ===============================================<html>
    <body>
    <script language="JavaScript" defer>
    <!--
    // specific to context menu extensions
    var win = external.menuArguments;// the document object the user right-clicked on
    var doc = win.document;// the html string composing most of the document (everything inside the <HTML></HTML> tags
    var szsource = "";
    szsource = doc.documentElement.outerHTML;// make sure our debugging window is a unique window
    var wincounter = 0;var mywin = window.open("about:blank", "fullsource" + wincounter++, "toolbar=no,location=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
    while (mywin == null) {
    mywin = window.open("about:blank", "fullsource" + wincounter++, "toolbar=no,location=no,menubar=yes,status=yes,scrollbars=yes,resizable=yes");
    } // if (mywin == null)var myDoc = mywin.document;myDoc.open("text/plain");
    myDoc.write(szsource);
    myDoc.close();
    myDoc.title = "Full Source for: " + win.location.href;
    // -->
    </script>
    </body>
    </html>=====================================================
      

  7.   

    2、创建一个“FullSource.inf”文件
    内容如下:
    ===========================================[Version]
    Signature="$Chicago$"
    Provider="ThunderMain Ltd"[DestinationDirs]
    DefaultDestDir=10,"web"[DefaultInstall]
    AddReg=FullSource_AddReg
    CopyFiles=FullSource_CopyFiles[FullSource_CopyFiles]
    FullSource.html[FullSource_AddReg]
    HKCU,"Software\Microsoft\Internet Explorer\MenuExt\DHTML代码(&F)",,0x00000000,"%10%\web\FullSource.html"==========================================================
      

  8.   

    to 楼上的,
    打算做在 ie 菜单里? 汗。
    呵呵。
      

  9.   

    assdeng(山野村夫) 不行啊,说一下喂
      

  10.   

    最多只能回3次
    我的话还没有说完就进不来了,急死了如scsjs(闪电回归)所说,做到IE的右键菜单里将上面两个文件放在同一目录下,FullSource.inf >> 右键 >> 安装
    然后在IE右键菜单中就回出现“DHTML代码”项通过这样的办法可以查看用innerHtml方法动态生成的完整的HTML代码
      

  11.   

    <script>
    var xmlhttp=new ActiveXObject("Microsoft.xmlhttp");
    xmlhttp.open("GET","http://localhost/test/test3.htm",false);
    xmlhttp.send();
    alert(xmlhttp.responseText)
    </script>
      

  12.   

    to  s1ihome(把握住今天)呵呵,过一会儿,又有编码,转换的问题了,
    再过一会儿,又有字符串连接速度过慢的问题了。
    xmlhttp 很好用,也很烦的说。to assdeng(山野村夫)
    先前做了一个FLASH导出链接的,和文本提取的,也是放在IE菜单里。
    不过现在觉的
    C:\Program%20Files\Microsoft%20Office\OFFICE11\2052\ocltint.dll/commbar.htm
    把这个文件也替换了,讨论功能换成自己的页面。
    要不右键被屏蔽了很烦的说。