DECLARE_EVENTSINK_MAP()
在.cpp文件中的代码如下
BEGIN_EVENTSINK_MAP(CFindJSDlg,CDHtmlDialog)
ON_EVENT(CFindJSDlg, AFX_IDW_PANE_FIRST, DISPID_NEWWINDOW3, OnNewWindow3, VTS_PDISPATCH VTS_PBOOL VTS_I4 VTS_BSTR VTS_BSTR)
ON_EVENT(CFindJSDlg, AFX_IDC_BROWSER, 251,OnNewWindow2, VTS_PDISPATCH VTS_PBOOL)
END_EVENTSINK_MAP()
.....
void CFindJSDlg::OnNewWindow3(LPDISPATCH* ppDisp,BOOL* Cancel,unsigned long dwFlags, LPCTSTR bstrUrlContext,LPCTSTR bstrUrl)
{
*Cancel = true;//禁止跳转
AfxMessageBox(_T("BBB"));
Navigate(_T("http://www.realsung.com"));
}
void CFindJSDlg::OnNewWindow2(LPDISPATCH* ppDisp,BOOL* Cancel)
{
AfxMessageBox(_T("OnNewWindow2 alter you : you are going to open url - :"));
WNDPROC* superProc;
superProc = this->GetSuperWndProcAddr();
}
在打开页面的时候,现实的情况是,OnNewWindow2可以捕获下面这个新窗口的弹出!
<a id="A1" href="http://www.baidu.com/" target="_blank">Hello world</a>
但是,OnNewWindow3却不能打开这个!
<BUTTON STYLE="WIDTH:100" ID="ButtonOK" onclick="javascript:window.showModelessDialog('1.html');">确定</BUTTON>
请问怎么才能让showModelessDialog弹出新窗口的时候,能进入OnNewWindow3啊?
4 个解决方案
#1
似乎不支持,看MSDN的补充说明:
http://msdn.microsoft.com/en-us/library/aa768288%28v=VS.85%29.aspx
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
#2
那么在CDHtmlDialog里面怎么能够截获javascript里面的showModalDialog并控制啊?
#3
Hook JS 函数.
#4
请指教啊!
我现在用
头文件中放这个:
DECLARE_DISPATCH_MAP()
void showModalDialog(VARIANT& str1, VARIANT& str2, VARIANT& params);
在代码文件中放这个
BEGIN_DISPATCH_MAP(CRealsungBrowserDlg, CDHtmlDialog)
DISP_FUNCTION(CRealsungBrowserDlg,"showModalDialog",showModalDialog,VT_EMPTY,VTS_NONE)
END_DISPATCH_MAP()
void CRealsungBrowserDlg::showModalDialog(VARIANT& url, VARIANT& window, VARIANT& params)
{
CComVariant varStr1(url),varStr2(window);
varStr1.ChangeType(VT_BSTR);
varStr2.ChangeType(VT_BSTR);
USES_CONVERSION;
CString strMsg;
strMsg.Format(_T("varStr1:%s,varStr2:%s"),OLE2T(varStr1.bstrVal),OLE2T(varStr2.bstrVal));
AfxMessageBox(strMsg);
}
然后再JS文件中使用window.external.showModalDialog("111","111","1111")
确无法调用,提示说方法未注册!!
#1
似乎不支持,看MSDN的补充说明:
http://msdn.microsoft.com/en-us/library/aa768288%28v=VS.85%29.aspx
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
Note The NewWindow3 event is only fired when a new instance of Internet Explorer is about to be created. Calling showModalDialog or showModelessDialog does not trigger an event because they are not new instances of Internet Explorer. They are implemented as MSHTML host windows, which allows them to render and display HTML content but not hyperlinks between documents.
#2
那么在CDHtmlDialog里面怎么能够截获javascript里面的showModalDialog并控制啊?
#3
Hook JS 函数.
#4
请指教啊!
我现在用
头文件中放这个:
DECLARE_DISPATCH_MAP()
void showModalDialog(VARIANT& str1, VARIANT& str2, VARIANT& params);
在代码文件中放这个
BEGIN_DISPATCH_MAP(CRealsungBrowserDlg, CDHtmlDialog)
DISP_FUNCTION(CRealsungBrowserDlg,"showModalDialog",showModalDialog,VT_EMPTY,VTS_NONE)
END_DISPATCH_MAP()
void CRealsungBrowserDlg::showModalDialog(VARIANT& url, VARIANT& window, VARIANT& params)
{
CComVariant varStr1(url),varStr2(window);
varStr1.ChangeType(VT_BSTR);
varStr2.ChangeType(VT_BSTR);
USES_CONVERSION;
CString strMsg;
strMsg.Format(_T("varStr1:%s,varStr2:%s"),OLE2T(varStr1.bstrVal),OLE2T(varStr2.bstrVal));
AfxMessageBox(strMsg);
}
然后再JS文件中使用window.external.showModalDialog("111","111","1111")
确无法调用,提示说方法未注册!!