如果包含Editor.htm的页面没有装载完就取不到的

解决方案 »

  1.   

    demo.htm<OBJECT id="doc_html" data="t.htm" type="text/x-scriptlet"  VIEWASTEXT></OBJECT><script language="vbscript">
    Function bytes2BSTR(vIn)
    Dim strReturn,i,ThisCharCode,innerCode,Hight8,Low8,NextCharCode
    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
    </script>
    <script language="javascript">
    function getHTML(url)
    {
    var xmlhttp= new ActiveXObject("Msxml2.xmlhttp");
    xmlhttp.open("GET",url,false);
    xmlhttp.send();
    return bytes2BSTR(xmlhttp.ResponseBody);
    }
    alert(getHTML(doc_html.data))
    </script>
      

  2.   

    ratnight:    Editor.htm页面肯定装载完了,希望你不是在灌水!
    灰豆宝宝.net:    只是取一个元素的内容,用不到那么麻烦吧?!
      

  3.   

    是不好弄,楼楼看看这个例子,希望对你有帮助
    main.html
    <!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html>
    <head>
    <title> New Document </title>
    <meta name="Generator" content="EditPlus">
    <meta name="Author" content="">
    <meta name="Keywords" content="">
    <meta name="Description" content="">
    <script language="JavaScript">
    <!--
    function init()
    {
      document.all.doc_html.contents = "kisslan  :)";
    }
    //-->
    </script>
    </head><body bgcolor="#FFFFFF" onload="init()">
    <object id="doc_html" name="doc_html" width=598 height=320 data="edit.html" type="text/x-scriptlet"></object>
    </body>
    </html>
    edit.html
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <script language="javascript">
    var targetDoc;
    public_description = new editor;
    function editor()
    {
     this.put_contents = PutContents;
    }
    function PutContents(contents)
    {
      targetDoc.designMode = "On";
      if (target.document.all["cdiv"]!=null) target.document.all["cdiv"].innerHTML = contents;
      else target.document.body.innerHTML = contents;
    }
    </script>
    </head>
    <body onload="editor()">
    <iframe id=target name=target scrolling="yes" marginwidth=1 style="HEIGHT: 100%; WIDTH: 100%">
    </iframe>
    </script>
    </body>
    <script>
    targetDoc = document.frames.target.document;
    targetDoc.designMode = "On";
    </script>