0

I'm using WebBrowser control to load my page. I want to hide all the html elements in the page apart from a particular div (and its children). I've the id of that particular div. How can I hide all the other elements?

Edit

I'm creating the webbrowser instance dynamically. I want to navigate to a URL and take a screen shot of the page partially (a particular div). So I want to hide all the other elements in the page and take a screenshot.

NLV
  • 21,141
  • 40
  • 118
  • 183
  • I think you can replace or remove that element by id and then load to WebBrowser – Viktor Apoyan May 11 '11 at 13:26
  • Can you please explain a bit further? – NLV May 11 '11 at 13:32
  • clarify please: Is the "webbrowser" control residing in a C# winforms. Are you wanting the 'host' application to affect the page as it is being loaded from another source? Is your page being loaded locally or from a server? Is the page html only, asp.net, other...? do you control the page? Are you wanting to hide the other elements so that they can be revealed dynamically? – Cos Callis May 11 '11 at 13:33
  • Have you seen this post http://stackoverflow.com/questions/2492544/how-to-hide-htmlelement-in-webbrowser-control/2492648#2492648 ? – Viktor Apoyan May 11 '11 at 13:34
  • Yes I know how to hide a particular element. But I want to know how can I hide all the elements except a particular element. I tried looping through the elements checking the ID and try to hide it (except my div and its children). But it is not working. – NLV May 11 '11 at 13:37

1 Answers1

0

I used JQuery to hide all the elements apart from my div and its children. I referred this post for the script and called the script in the webbrowser using InvokeScript(). It worked perfectly.

Community
  • 1
  • 1
NLV
  • 21,141
  • 40
  • 118
  • 183