1,禁止webbrowser弹出窗口
发现Silent不管用的,不知道是不是我用的不对,alert还是会弹出的
找了一段代码,(未测试)
LPDISPATCH lpDispatch = m_explorer.GetDocument(); IHTMLDocument2* pDocument; lpDispatch->QueryInterface(IID_IHTMLDocument2, (void**)&pDocument); lpDispatch->Release(); if ( pDocument != NULL ) { CComQIPtr<IHTMLWindow2> pHTMLWnd; pDocument->get_parentWindow( &pHTMLWnd ); if ( pHTMLWnd != NULL ) { CComBSTR bstrjs = L"function showModalDialog(){return;}"; CComBSTR bstrlan = SysAllocString( bstrjs ); VARIANT varRet; pHTMLWnd->execScript(bstrjs, bstrlan, &varRet); bstrjs = L"function Alert(){return;}"; bstrlan = SysAllocString( bstrjs ); pHTMLWnd->execScript(bstrjs, bstrlan, &varRet); bstrjs = L"function confirm(){return;}"; bstrlan = SysAllocString( bstrjs ); pHTMLWnd->execScript(bstrjs, bstrlan, &varRet); } }
2,禁止webbrowser读取缓存
使用VARIANT flag; flag.vt = VT_I4; flag.iVal = navNoHistory + navNoReadFromCache + navNoWriteToCache; m_explorer.Navigate( strToUrl, &flag, NULL, NULL, NULL ); 也不管用
在论坛上看到有人提供的一个高招,在连接末尾加上&xxxx这样的随即字符串,不影响访问的
发表于 @ 2009年04月07日 22:31:00 | 评论( loading... ) | 编辑| 举报| 收藏