简体   繁体   English

使用WebBrowser控件-隐藏除一个Div之外的所有HTMLElement

[英]Using WebBrowser Control - Hiding all the HTMLElements apart from one Div

I'm using WebBrowser control to load my page. 我正在使用WebBrowser控件加载页面。 I want to hide all the html elements in the page apart from a particular div (and its children). 我想隐藏页面中除特定div(及其子元素)之外的所有html元素。 I've the id of that particular div. 我有那个特定div的ID。 How can I hide all the other elements? 如何隐藏所有其他元素?

Edit 编辑

I'm creating the webbrowser instance dynamically. 我正在动态创建webbrowser实例。 I want to navigate to a URL and take a screen shot of the page partially (a particular div). 我想导航到一个URL并对该页面进行部分屏幕截图(特定div)。 So I want to hide all the other elements in the page and take a screenshot. 因此,我想隐藏页面中的所有其他元素并截屏。

I used JQuery to hide all the elements apart from my div and its children. 我使用JQuery隐藏了除div及其子元素之外的所有元素。 I referred this post for the script and called the script in the webbrowser using InvokeScript(). 我引用了该帖子的脚本,并使用InvokeScript()在webbrowser中调用了该脚本。 It worked perfectly. 效果很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM