首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

怎样给IFRAME元素赋值?解决思路

2012-01-14 
怎样给IFRAME元素赋值?IFRAME idpost tabIndex2 height320 srcblank.htm width550 namepost/IF

怎样给IFRAME元素赋值?
<IFRAME id=post tabIndex=2 height=320 src="blank.htm" width=550 name=post></IFRAME>
怎样对这个IFRAME元素赋值呢?
这个blank.htm里面啥也没有
就是
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title></title>
</head>
<body>
</body>
</html>
就完了,我怎么给他赋值都赋值不上去

C/C++ code
CComQIPtr<IHTMLElement> spFrame_Content;            hr = spIHTMLDoc3->getElementById(L"post",&spFrame_Content);            if (SUCCEEDED (hr) && spFrame_Content!= NULL )            {                SetValue(spFrame_Content,DataProvider::GetFinalString());                CComPtr<IHTMLFrameBase2>   pFrameBase2;                   hr=spFrame_Content->QueryInterface(IID_IHTMLFrameBase2,(void**)&pFrameBase2);                   if(hr==S_OK)                   {                       CComPtr<IHTMLWindow2>   pWindow2;                       hr=pFrameBase2->get_contentWindow(&pWindow2);                       if(hr==S_OK)                       {                           CComPtr<IHTMLDocument2>   pDoc2Frame;                           hr=pWindow2->get_document(&pDoc2Frame);                           if   (hr==S_OK)                           {                               //得到IHTMLDocument2                             CComQIPtr<IHTMLElementCollection > spInput_Body;                            hr = spIHTMLDoc3->getElementsByTagName(L"body",&spInput_Body);                            long nCollectionCount=0;                //取得表单数目                            hr = spInput_Body->get_length( &nCollectionCount );                            if ( FAILED( hr ) )return;                            for(long i=0; i<nCollectionCount; i++)                            {                                IDispatch *pDisp = NULL;    //取得第 i 项表单                                hr = spInput_Body->item( CComVariant( i ), CComVariant(), &pDisp );                                if ( FAILED( hr ) || pDisp == NULL)        continue;                                CComQIPtr< IHTMLElement > spElement = pDisp;                                //spElement->put_innerText(DataProvider::GetFinalString().AllocSysString());                                spElement->put_outerText(DataProvider::GetFinalString().AllocSysString());                            }                        }                     }                }            }

这段代码赋值不上~先甭管CString::AllocSysString()的内存泄露问题。
直接用 spFrame_Content的赋值也赋值不上。无语了,没招了。

[解决办法]
去.net问问
[解决办法]
body 里面都没有元素怎么赋值啊?

如果 spInput_Body 是有效的话,试试

spInput_Body->put_innerHTML(...);

热点排行