3

I have one winform application. I can get HTML of page using webclient call or HtmlAgilityPack.dll

but issue is that HTML is getting without javascript execution ... let me explain..

let say one div is in HTML page which is hide by javascript using style=display:none; but when I get html using these techniques i can not get this div hidden... it shows me that div...

SOF User
  • 7,590
  • 22
  • 75
  • 121

1 Answers1

1

The problem is that JavaScript is generally only executed when you render a page. In .net winforms there is a web browser control. If you add this to your form and navigate it to the web page it will execute javascript as you would normally expect. You can then google for samples of how to obtain the resulting DOM/HTML. If you want to avoid displaying the WebBrowser you may be able to just instantiate it in code behind instead and, failing that, try just giving it a height and width of 0.

ForbesLindesay
  • 10,482
  • 3
  • 47
  • 74
  • I tried did already... but if we put web browser control then it its own issue .. its completed event occur many time ... and then I google so i found its readystate property should be complete but i found it still fire this event with readystate property complete many time – SOF User Aug 14 '11 at 01:23
  • It's not an ideal solution, but you could use something like reactive extensions with Throttle, to reduce the number of times it's fired. That way you only handle the last event in each time you navigate. – ForbesLindesay Aug 14 '11 at 04:44