IHTMLWindow2的get_document方法有时候会返回E_ACCESSDENIED
当一个page有多个sub frame的时候,如果frame的src在不同的domain上,就会返回这个错误,真是郁闷,在网上找了一些资料,没用太多有用的信息,最后还是MSDN解决问题,呵呵
解决的办法就是通过 IWebBrowser2 的 IOleContainer 接口访问所有的frame,代码如下
HRESULT CBhoOfPopBars::GetSelectionByOleContainer( CString& selText, CRect& selRect )
{
// Get the IDispatch of the main document
CComPtr
m_pBrowser->get_Document( &pDisp );
if( » 阅读更多: IHTMLWindow2的get_document方法有时候会返回E_ACCESSDENIED