Sunday, February 19, 2012

IHTMLDocument2 E_ACCESSDENIED

Hi,

Do anyone know why I got the E_ACCESSDENIED error?

CComQIPtr<IHTMLFrameBase2> pFrameBaseElem( pElemDisp );

if (pFrameBaseElem != NULL)

{

LONG celem2 = 0;

CComPtr<IHTMLWindow2> pFrameWindow;

CComPtr<IHTMLDocument2> pFrameDoc;

CComPtr<IHTMLElementCollection> pElemColl2 = NULL;

hr = pFrameBaseElem->get_contentWindow(&pFrameWindow);

if (pFrameWindow != NULL)

{

hr = pFrameWindow->get_document(&pFrameDoc);

if (pFrameDoc != NULL) //Work if the frame src is within the same home address. fails if the frame src is other web site.

Thanks

Not sure this is the forum you wanted for this question, but this behavior is by design. You can not access content in a frame whose content is from a different domain. Allowing you to do so would be a security hole.

-Daniel

No comments:

Post a Comment