描述:
m_pWebBrowser->get_document( &pDisp);
hr = pDisp->QueryInterface(IID_IHTMLDocument2, (void**)&pDoc2);
while(pDoc2)
{
IHTMLElement* pElement;
if(SUCCEEDED(pDoc2->get_activeElement(&pElement)))
{
pDoc2->Release();
pDoc2 = NULL;
CComBSTR tagName;
pElement->get_tagName(&tagName);
CString str = tagName;
str.MakeUpper();
if (str == "FRAME" || str == "IFRAME")
{
HRESULT hr;
IHTMLWindow2 *pHTMLWindow;
IHTMLFrameBase2* pHTMLFrameBase2;
hr =pElement->QueryInterface(IID_IHTMLFrameBase2, (void**)&pHTMLFrameBase2);
pElement->Release();
hr = pHTMLFrameBase2->get_contentWindow(&pHTMLWindow);
pHTMLFrameBase2->Release();
/********************************************************* ***********************************************************/
//关键文题在这里
hr = pHTMLWindow->get_document(&pDoc2);
/********************************************************* ***********************************************************/
}
else
{
VARIANT_BOOL bText;
pElement->get_isTextEdit(&bText);
if (bText == VARIANT_TRUE)
{
return pElement;
}
else
pElement->Release();
}
}
}
以上代码对很多包含Frame网页都适用,包括CSDN的BBS,但对网易BBS,西陆社区
hr = pHTMLWindow->get_document(&pDoc2);不成功,错误信息是没有权限。
如何解决这个问题?
解决方案1:
老兄,我也遇到这个问题了,
55555555555555!!!
这是安全性的限制,除了自定义Internet安全管理器之外我不知道有没有办法解决
你可以去msdn online搜索IInternetSecurityManager查找相关文档
这个是安全性的限制,你看看是不是在访问另外一个domain。不同domain的似乎不能垮框架访问