标签:引用 navigate obj 代码 rip logs ext script .dll
1.为展示效果较好,确定好webbrowser尺寸后,调整网页布局(一般都是网页内容往左上方向移动)
2.一些简单代码
引用Microsoft.mshtml.dll
<WebBrowser Name="CamWeb" LoadCompleted="CamWeb_LoadCompleted">
1 string szTmp = "http://www.baidu.com"; 2 Uri uri = new Uri(szTmp); 3 CamWeb.Navigate(uri); 4 5 ...... 6 7 8 private void CamWeb_LoadCompleted(object sender, NavigationEventArgs e) 9 { 10 ((sender as WebBrowser).Document as mshtml.HTMLDocumentEvents_Event).oncontextmenu += SettingWindow_oncontextmenu; 11 mshtml.HTMLDocument dom = (mshtml.HTMLDocument)CamWeb.Document; //定义HTML 12 dom.documentElement.style.overflow = "hidden"; //隐藏浏览器的滚动条 13 dom.body.setAttribute("scroll", "no"); //禁用浏览器的滚动条 14 mshtml.IHTMLDocument2 doc = CamWeb.Document as mshtml.IHTMLDocument2; 15 doc.parentWindow.execScript("document.body.style.zoom=" +1.0 + ";");//缩放页面,自行调整数值 16 17 } 18 19 bool SettingWindow_oncontextmenu() 20 { 21 //throw new NotImplementedException(); 22 return true; 23 }
标签:引用 navigate obj 代码 rip logs ext script .dll
原文地址:http://www.cnblogs.com/dyfisgod/p/7765410.html