none
IE8,BHO call createElement and appendChild functions, but no effect! RRS feed

  • 问题

  • Hello,

            It run successfully on the internet explorer 6.0 and 7.0. but on the internet explorer 8.0, the functions have been called successfully, but it have no effect!

            Is that because I do not have a digital signature?

     

    Code:

    CComPtr<IHTMLElement> pBodyHTMLElement;
     hr=pHTMLDocument2->get_body(&pBodyHTMLElement);
     if (FAILED(hr))
     {
      return -1;
     }
    
    
     CComQIPtr<IHTMLDOMNode, &IID_IHTMLDOMNode>  spHTMLDOMNodeBody(pBodyHTMLElement);
    
    
     CComQIPtr<IHTMLElement>  spElemTemp;
     hr=pHTMLDocument2->createElement(L"div", &spElemTemp);
     if (FAILED(hr))
     {
      return -1;
     }
    
    
     hr = spElemTemp->setAttribute(L"id", variant_t(L"n_div"));
     if (FAILED(hr))
     {
      return -1;
     }
    
    
     hr = spElemTemp->put_innerHTML(L"aaaaaaaaaaa");
     if (FAILED(hr))
     {
      return -1;
     }
    
    
     CComQIPtr<IHTMLDOMNode>  spHTMLDOMNodeTemp(spElemTemp);
     CComQIPtr<IHTMLDOMNode>  spHTMLDOMNode;
     hr=spHTMLDOMNodeBody->appendChild(spHTMLDOMNodeTemp, &spHTMLDOMNode);
     if (FAILED(hr))
     {
      return -1;
     }
    
    

    2011年6月22日 14:30

答案