如何通过IHTMLDocument2接口获得网页中id =content1的编辑框中的值,其实在这个网页里已经有一个按钮
<input type="button" name="button" value="取得内容" onclick="javascript:alert(KE.util.getData('content1'));" />可以获得编辑框的值,就是不知道怎么把它取出来,找了很多代码 IHTMLDocument2 *pIHTMLDocument2 ;
pIHTMLDocument2 =(IHTMLDocument2*)m_htmlShow.GetDocument();
if ( !pIHTMLDocument2 ) return;
HRESULT hr;
获得IHTMLDocument2接口之后就不知道怎么办了,大家帮帮我
<input type="button" name="button" value="取得内容" onclick="javascript:alert(KE.util.getData('content1'));" />可以获得编辑框的值,就是不知道怎么把它取出来,找了很多代码 IHTMLDocument2 *pIHTMLDocument2 ;
pIHTMLDocument2 =(IHTMLDocument2*)m_htmlShow.GetDocument();
if ( !pIHTMLDocument2 ) return;
HRESULT hr;
获得IHTMLDocument2接口之后就不知道怎么办了,大家帮帮我
hr = m_pIHTMLDocument2 ->getElementById(elemId,&pElem);
if(SUCCEEDED(hr))
{
...
}
if(SUCCEEDED(hr))
{
...
}
省略号里应该填什么?pElem.value;吗?
pIHTMLDocument2 =(IHTMLDocument2*)m_htmlShow.GetDocument();
CComPtr <IHTMLElement> pElem;
hr = m_pIHTMLDocument2 ->getElementById(elemId,&pElem);
if(SUCCEEDED(hr))
{
CString value = pElem->get_value();
}value 就是你要的值
m_pIHTMLDocument2 这个是什么?elemId这个呢?
编译错误如下:
error C2065: 'm_pIHTMLDocument2' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1\1View.cpp(110) : error C2227: left of '->getElementById' must point to class/struct/union
C:\Documents and Settings\Administrator\桌面\1\1View.cpp(110) : error C2065: 'elemId' : undeclared identifier
C:\Documents and Settings\Administrator\桌面\1\1View.cpp(113) : error C2039: 'get_value' : is not a member of '_NoAddRefReleaseOnCComPtr<struct IHTMLElement>'
Error executing cl.exe.1.exe - 4 error(s), 0 warning(s)