如题!我现在做的是在单个页面中是没问题的,但是如果一个页面中包含iframe,就会出现问题了,我想在DISPID_BEFORENAVIGATE2事件中判断如果是iframe就不进行任何操作,问题是不知道怎么做,GOOGLE了一下也没有结果.期待大家的回复!
这个问题在
http://community.csdn.net/Expert/TopicView3.asp?id=4724150
中有解答,但我用还是有问题问题是:
lion_wing(凤之焚) 的方法在DISPID_DOCUMENTCOMPLETE事件中是有效的
甚至可以简化成
if(m_pWebBrowser2 == pDispParams->rgvarg[1].pdispVal)
{//执行操作}
else
{//不执行}但这个方法在DISPID_BEFORENAVIGATE2却无效
pDispParams->rgvarg[1].pdispVal得到的地址和m_pWebBrowser2不同~~唉,真是不知道怎么回事~~请高手来看看
好像lion_wing(凤之焚)现在也经常活跃在这里,麻烦你帮帮忙~~万分感谢~~

解决方案 »

  1.   

    you want get the target frame?TargetFrameName
        Stringexpression that evaluates to the name of the frame in which the resource will be displayed, or Null if no named frame is targeted for the resource.If you need to find which frame is navigating, handle the first NavigateComplete event after the last DocumentComplete event
      

  2.   

    我在OnBeforeNavigate2中,加载一个多FRAME的网页:
    USES_CONVERSION;

    CComVariant strUrl(*TargetFrameName);
    strUrl.ChangeType(VT_BSTR);
    MessageBox(OLE2T(strUrl.bstrVal));
    结果都用空。
    我再看看
      

  3.   

    if (pDispParams->cArgs >= 6 && pDispParams->rgvarg[6].vt == VT_DISPATCH) {
        pDispatch = &(*pDispParams->rgvarg[6].pdispVal);
        CComQIPtr<IUnknown, &IID_IUnknown> pUnk1;
        CComQIPtr<IUnknown, &IID_IUnknown> pUnk2;
        HRESULT hr1 = m_pWebBrowser->QueryInterface(IID_IUnknown,  (void**)&pUnk1);
        HRESULT hr2 = pDispatch->QueryInterface(IID_IUnknown, (void**)&pUnk2);
        if (pUnk1 != pUnk2) {
            // 为iframe
            return S_FALSE;
        }
    }
      

  4.   

    呵呵~~,我也试出来了是第rgvarg[6].pdispVal个参数谢谢大家~~更简单点
    if (pDispParams->cArgs >= 6 && pDispParams->rgvarg[6].vt == VT_DISPATCH) {
      if(m_pWebBrowser2 == pDispParams->rgvarg[6].pdispVal)
      {//执行操作}
      else
      {//不执行}
    }