webBrowser control cannot find htmlElement after Ajax webpage update or in frame
Using webBrowser control in a winForm. but when the webpage is updated by Ajax or in a frame, I cannot use
webBrowser1.document.getElementById
, etc. to find that htmlElement
. The element also won't show in the View->Source c开发者_如何学Goode
in IE.
The untimate purpose is to find that htmlElement
and simulate a click or other function like
invokeMember("staff")
.
The WebBrowser's Document object does indeed represent a live view of the DOM so there may be some other reason that you're unable to find it. DOM updates will not however be represented in View -> Source. You should use IE8's developer tools which will show you a live view of the DOM and maybe you'll see something like an incorrect/duplicate ID or something.
I'm guessing you have already solved this problem on your own, but if you haven't, refer to my question here: WebBrowser Control and GetElement by ID
Essentially, if you do something to the WebBrowser control (ie, add some member to the DOM) it will do so asynchronously. That is, it does it on another thread, that way it avoids locking your calling thread when the WebBrowser is doing work. The problem is that if you programatically modify something with a command, you will have to wait till that command actually finishes loading its changes till you can work with the result of it.
Check my question there for a code example of what I was doing. I hope someone can find my previous trials useful.
精彩评论