2 个解决方案
#1
Navigate("javascript:alert('1');");
#2
void CTest_jsDlg::OnBnClickedButton2()
{
IHTMLDocument2 *pHTMLDocument=NULL;
if (!(pHTMLDocument = (IHTMLDocument2*)m_Ie.get_Document()))
return;
CString sScript = L"AddMsg(1,\'zxc\',\'11:25\',\'sdfsdfsdf\',0)";//此处为要调用的js函数
CString Type = L"javascript";
IHTMLWindow2 *m_pHtmlWindow=NULL;
pHTMLDocument->get_parentWindow(&m_pHtmlWindow);
VARIANT ret;
ret.vt = VT_EMPTY;
BSTR bstr = sScript.AllocSysString();
BSTR btype = Type.AllocSysString ();
m_pHtmlWindow->execScript(bstr,btype , &ret);
::SysFreeString(bstr);
::SysFreeString(btype);
}
#1
Navigate("javascript:alert('1');");
#2
void CTest_jsDlg::OnBnClickedButton2()
{
IHTMLDocument2 *pHTMLDocument=NULL;
if (!(pHTMLDocument = (IHTMLDocument2*)m_Ie.get_Document()))
return;
CString sScript = L"AddMsg(1,\'zxc\',\'11:25\',\'sdfsdfsdf\',0)";//此处为要调用的js函数
CString Type = L"javascript";
IHTMLWindow2 *m_pHtmlWindow=NULL;
pHTMLDocument->get_parentWindow(&m_pHtmlWindow);
VARIANT ret;
ret.vt = VT_EMPTY;
BSTR bstr = sScript.AllocSysString();
BSTR btype = Type.AllocSysString ();
m_pHtmlWindow->execScript(bstr,btype , &ret);
::SysFreeString(bstr);
::SysFreeString(btype);
}