WebBrowser: how to see updates to DOM made by JavaScript? RRS feed

  • Question

  • If a web page being displayed in a WebBrowser control is being updated by JavaScript, is it possible to get an updated DOM document that reflects the changes made by that script?

    For example, go to starbucks.com, enter a US zip code into the "Store Locator" dialog box at the top right, then click "go". The page will display a "Did you mean..." disambiguation dialog box that is created by JavaScript: a script creates an HTML string, then sets the innerHTML property of a div in the location box.

    In my code, I create a WebBrowser control and Navigate to starbucks.com. When the page loads, I receive a DocumentCompleted event, as expected. I then (programmatically) enter a zip code and click the "go" button. In the WebBrowser, I see the "Did you mean..." dialog being displayed, and I receive a second DocumentCompleted event. WebBrowser.Document, however, has not changed, and the div that was updated by the JavaScript is as it was when the page first loaded. I've also tried calling ExecuteScript("document.getElementByID(\"div_name"\"), which only returns null, so no luck there either.

    Any suggestions? Or can the WebBrowser control only deal with full page loads?

    • Moved by Bruno Yu Wednesday, June 4, 2008 6:51 AM Off-Topic post in BCL forum.
    Saturday, May 31, 2008 10:26 PM

All replies