• 全部
  • C#综合技术
  • C#互联网桌面应用
  • AppLauncher
  • WinForm&WPF
  • C#开发新技术
  • 问答

|ZYCIIS| 如何让WebBrowser不显示和不下载jpg gif png的文件呢? 谢谢

javamy010 2012-12-08 11:42:11
我要用WebBrowser去浏览网站,
因为速度要求,
要求不要去下载图片资源
那WebBrowser应该如何来实现
谢谢

PS:是不下载图片资源,并不是说在WebBrowser中显示后把图片标签去掉

谢谢
...全文
180 点赞 收藏 6
写回复
6 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
javamy010 2012-12-11
引用 5 楼 findcaiyzh 的回复:
Controlling Download and Execution The WebBrowser Control gives you control over what it downloads, displays, and executes. To gain this control, you need to implement your host's IDispatch so it h……
C++的东西还是看不懂啊。。。
回复
javamy010 2012-12-10


        private void wbSite_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            if (this.wbSite.Document != null)
            {
                var doc = this.wbSite.Document;
                if (doc != null)
                {
                    var imgs = doc.GetElementsByTagName("img");
                    //"edit_parent"
                    foreach (HtmlElement img in imgs)
                    {
                            Console.WriteLine(img.InnerHtml);
                            img.SetAttribute("src", "");
                            img.SetAttribute("alt", "去除");
                    }
                    var links = doc.GetElementsByTagName("link");
                    foreach (HtmlElement link in links)
                    {
                        Console.WriteLine(link.InnerHtml);
                        link.SetAttribute("href", "去除");
                    }
                }
               
            }
我用上面的方法的话,还是会在页面加载的时候显示图片和样式 如何才能让WebBorswer不显示图片和CSS样式呢? PS:是在不去改IE设置的前题 谢谢
回复
宝_爸 2012-12-10
Controlling Download and Execution The WebBrowser Control gives you control over what it downloads, displays, and executes. To gain this control, you need to implement your host's IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser Control is instantiated, it will call your IDispatch::Invoke with this ID. Set pvarResult to a combination of following flags, using the bitwise OR operator, to indicate your preferences. * DLCTL_DLIMAGES, DLCTL_VIDEOS, and DLCTL_BGSOUNDS: Images, videos, and background sounds will be downloaded from the server and displayed or played if these flags are set. They will not be downloaded and displayed if the flags are not set. 没试过,来自: WebBrowser Customization http://msdn.microsoft.com/en-us/library/aa770041(VS.85).aspx
回复
nonocast 2012-12-10
一个比较dirty的方法,写NDIS驱动,或者利用Winpcap拦截mime是image/*的HTTP请求
回复
threenewbee 2012-12-09
http://bbs.csdn.net/topics/200056000 http://msdn.microsoft.com/en-us/library/aa770041(VS.85).aspx 中的 Controlling Download and Execution
回复
javamy010 2012-12-09


        private void wbSite_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (this.wbSite.Document != null)
            {
                var doc = this.wbSite.Document;
                if (doc != null)
                {
                    var imgs = doc.GetElementsByTagName("img");
                    //"edit_parent"
                    foreach (HtmlElement img in imgs)
                    {
                         img.SetAttribute("src", "");
                    }

                }
                return;
            }
        }
我用这种方法,只是是网页加载后,再把图片去掉 如果在在加,但还没有加载资源的时候去掉 谢谢
回复
相关推荐
发帖
C#
创建于2007-09-28

10.5w+

社区成员

.NET技术 C#
申请成为版主
帖子事件
创建了帖子
2012-12-08 11:42
社区公告

让您成为最强悍的C#开发者