I am using a WebBrowser control. I edit some HTML inputs and click a button in the WebBrowser DocumentCompleted event handler. My problem is clicking the button I mentioned changes the content of the Document using AJAX, Knowing that I need to parse some information from the new changes. The question is: How can I detect when the document has finished loading the ne开发者_开发技巧w content. Is there any sort of an event handler like DocumentChanged.
Thanks in advance.
I figured you'd be back about this. The extensibility object model has no great support for observing scripting execution. It isn't practical, scripting code can run completely asynchronous from the page state at unpredictable times. If there are no reliable DOM modifications made by the script that you can read back then you have no great options beyond just spinning your wheels for a couple of seconds to give it 'enough time'. Shouldn't be a problem given that you run this in a worker thread, just use a System.Windows.Forms.Timer who's Tick event calls Application.ExitThread to end the thread.
No way to do that, I'm sure - WebBrowser control is very simple and poor-functional
Do you control the HTML of the document you're displaying ? If so, after the ajax changes have completed you can use Javascript to call a C# method in your parent form window.external.MyPublicMethodName()
instead. Your app needs to be running in Full Trust for this to work, and also to have set the browser ObjectForScripting object to the form itself e.g. this.webBrowser1.ObjectForScripting = this;
in your Form_Load event.
精彩评论