Retrieving text in IE works in JavaScript but not using ATL
"Angus Comber" <angus-v2qo0/[email protected]>
| Newsgroups | gmane.comp.windows.wtl |
|---|---|
| Message-ID | <BE12E2032DC74B29AD94627A6A6487F6@angusnotebook> |
Hello
I am trying to retrieve text in a TEXTAREA using ATL. I can retrieve using
this javascript and this html:
function fnGetText(){
var elem=document.getElementById("arid536870934");
alert("The textarea content of arid536870934 is " + "\"" +
oVDiv2.innerHTML + "\".");
}
<div arid=536870934 artype="Char" ardbn="Caller" class="df arfid536870934
ardbnCaller" style="z-
index:1029;top:441; left:13; width:237; height:21;">
<label class="label f6" for="x-arid536870934" style="top:4; left:0;
width:71;
height:17;">Caller</label><textarea class="text sr " wrap="off"
id="arid536870934" cols="20"
maxlen=255 style="top:0; left:76; width:135; height:21;"
rows=1></textarea>
</div>
but with this ATL code it doesn't work.
//m_spBrowser is a CComPtr<IWebBrowser2> m_spBrowser
CComPtr<IDispatch> spDispDoc;
HRESULT hr=m_spBrowser->get_Document(&spDispDoc);
if (FAILED(hr))
return 0;
USES_CONVERSION;
// ... and query for an HTML document
CComQIPtr<IHTMLDocument3> spDoc3 = spDispDoc;
if (!spDoc3)
{
MessageBox("Unable to get document object");
return 0;
}
CComPtr<IDispatch> spdispMyItem;
CComQIPtr<IHTMLElement> spMyItem;
hr=spDoc3->getElementById(T2BSTR("arid536870934"), &spMyItem);
CComBSTR bstrtext;
hr=spMyItem->get_innerHTML(&bstrtext);
get_innerText does not work either.
This is on IE6. Does anyone know what I am doing wrong?
How can I retrieve the text?
Angus
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/wtl/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/wtl/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/