目前只知道IHTMLDocument2 *pHtmlDocument = (IHTMLDocument2*)this->m_ie.GetDocument();然后通过 IHTMLDocument2 对象对HTML进行操作,但是。。如何修改HTML的元素值呢求助···

解决方案 »

  1.   

    void CHtmlEditorDlg::OnButton5() 
    {
    CString sa;
    BSTR bs;/* kkk
    m_ie.GetDocumentCharset(sa);
    MessageBox(sa,"提示");*/
    CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc=(IHTMLDocument2 *)m_ie.GetDocument();
    if(pDoc)
    {
    CComPtr<IHTMLElement> pElem;
    pDoc->get_activeElement(&pElem);//********元素
      if(pElem!=NULL)   
      { 
     pElem->QueryInterface(&pex);//+++++++++++++++++++++++++++++pElem->get_id(&bs);//get_tagName(&bs);
    MessageBox("1--"+(CString)bs,"提示");
    pElem->get_tagName(&bs);//get_tagName(&bs);
    MessageBox("3--"+(CString)bs,"提示");
    /*CComPtr<IHTMLTextAreaElement> ctxt;//文本域内的文字
    pElem->QueryInterface(&ctxt);
    if(ctxt)*/
    CComVariant vs;
    if(pElem->getAttribute(CComBSTR("name"),0,&vs)==S_OK)//kkk
    {
    //ctxt->get_name(&bs);
    MessageBox("3--"+(CString)vs.bstrVal,"提示");
    }
    //-----------------------
    if(pElem->getAttribute(CComBSTR("type"),0,&vs)==S_OK)
    {
    //ctxt->get_name(&bs);
    MessageBox("4--"+(CString)vs.bstrVal,"提示");
    }
    //---------
      }
    }
      

  2.   

    CComDispatchDriver spInputElement; //取得第 j 项表单域
    hr = spFormElement->item( CComVariant( j ), CComVariant(), &spInputElement );
    spInputElement.PutPropertyByName();//设置置顶input的值
    spFormElement->submit();//提交表单