一、CHtmlView设计一个简单浏览器,点击超链接如何屏蔽IE启动
void CExam_KY100View::OnNewWindow2( LPDISPATCH* ppDisp, BOOL* Cancel )
{
CComPtrpHTMLDocument2; m_pBrowserApp->get_Document((IDispatch **)&pHTMLDocument2); if (pHTMLDocument2!=NULL) { CComPtr pIHTMLElement; pHTMLDocument2->get_activeElement(&pIHTMLElement); if (pIHTMLElement!=NULL) { VARIANT url; HRESULT hr=pIHTMLElement->getAttribute(Lhref, 0, &url); if (SUCCEEDED(hr)) { hr=m_pBrowserApp->Navigate2(&url, NULL, NULL, NULL, NULL); if (SUCCEEDED(hr)) { *Cancel=TRUE; } } } } }
二、vs2005 webBrowser1 怎么指定让他不跳转到其他浏览器
在加载的时候订阅事件:
wbBrowser.NewWindow += new CancelEventHandler(wbBrowser_NewWindow);
void wbBrowser_NewWindow(object sender, CancelEventArgs e)
{
e.Cancel = true;
try
{
WebBrowser wbT = (WebBrowser)sender;
string url = wbT.Document.ActiveElement.GetAttribute(href);
wbT.Url = new Uri(url);
}
catch
{
}
}
三、js做的下拉菜单出现重叠
这是兼容性的问题,最好用jQuery来做,肯定不会出现这种情况的
- 相关评论
- 我要评论
-