最近做一个htmledit控件,通过IHTMLDocument2Ptr向CWebBrowser写入html字符,当字写入的字符串类似<iframe src='x.html'></iframe>时显示空白.

解决方案 »

  1.   

    试试写  <SCRIPT>DOCUMNET.WRITE(<iframe src='x.html'> </iframe>) </SCRIPT>呢?
      

  2.   

    void CHTMLWnd::WriteHTML(const CString& str,BOOL bUnicode)
    {
    ASSERT(m_pHTMLDocument != NULL);
    HRESULT hresult = S_OK;
    VARIANT *param;
    SAFEARRAY *tmpArray; //BSTR bsData = ToBSTR(str,bUnicode);
    BSTR bsData = str.AllocSysString();
    tmpArray = SafeArrayCreateVector(VT_VARIANT, 0, 1);
    if(tmpArray != NULL)
    {
    hresult = ::SafeArrayAccessData(tmpArray,(LPVOID*)&param);
    param->vt = VT_BSTR;
    param->bstrVal = bsData;
    hresult = SafeArrayUnaccessData(tmpArray);
    hresult = m_pHTMLDocument->write(tmpArray);
    //hresult = m_pHTMLDocument->close();   // awfrdf2 [1017]
    ASSERT (SUCCEEDED(hresult));
    }
    ::SysFreeString(bsData);
    if(tmpArray != NULL)
    {
    ::SafeArrayDestroy(tmpArray);
    }
    }这是读取html字符串的函数. CHTMLWnd是继承CWnd的类 CWebBrowser  m_Output; m_pHTMLDocument = m_Output.GetDocument(); 经测试,显示其它任何元素都正常,包括script脚本.就是显示不了框架中网页
      

  3.   

    没办法,用write生成的iframe没法交互,对他的操作返回的都是0x80070005,也就是拒绝访问。
    可能是IE没公布的细节。换个思路。
      

  4.   

    IHTMLDocument2Ptr向CWebBrowser写入  没这么试过
      

  5.   

    MSDN 上关于document.createElement(sTag)的说明,看来iframe是不好办啊In Microsoft Internet Explorer 4.0, the only new elements you can create are img, area, and option. As of Internet Explorer 5, you can create all elements programmatically, except frame and iframe. The properties of these created elements are read/write and can be accessed programmatically. Before you use new objects, you must explicitly add them to their respective collections or to the document.