在IE7中从C ++调用window.execScript会导致错误80020101

时间:2011-06-06 19:09:58

标签: c++ internet-explorer-7

我使用以下代码调用javascript函数。 它在IE6和8中工作正常。 在IE7中,它会导致错误80020101

    MSHTML::IHTMLWindow2Ptr  win = 
                 static_cast<MSHTML::IHTMLDocument2Ptr>(m_pHTMLDocument)->parentWindow;
    m_pBrowser->Silent = VARIANT_TRUE;
    ss << " var e = document.getElementById(\"___functionCallResult___\");  "
           "if( e == null ) e = document.createElement(\"div\"); "       
           "e.style.visibility=\"hidden\"; e.id = \"___functionCallResult___\""      
           "e.innerHTML = ((document.getElementById(\"XX\") != null) ? " 
           "XX.GetValue(500):\"__WrongWindow__\");  document.body.appendChild(e);"
     _bstr_t bstrScript = ss.str().c_str();  
     win->execScript( bstrScript , L"JavaScript");
     MSHTML::IHTMLElementPtr pElement = NULL;
     pElement = m_pHTMLDocument->getElementById("___functionCallResult___");
     if( pElement ) 
     {
       _bstr_t bstrResult = pElement->innerHTML;
       if( bstrResult.length()) 
         retval = bstrResult;
     }

0 个答案:

没有答案