|
Rank: Newbie Groups: Member
Joined: 9/16/2015 Posts: 6
|
Hello,
Has anyone got a good way to detect changes to a loaded HTML document in a WebControl/WebView? I'm hosting the HTML-document in a WPF app, and it's in the WebControl contained in a WYSIWYG-editor that lets the user make stylistic changes to the HTML document, as well as type text into the document. When such a change occurs, I need to activate a Save-button in the WPF app, but I can't seem to find a good way to let the WPF know there's been DOM-changes.
Thank you
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
Hi, There is no built-in detection on our API. However I believe it is possible to do this in JavaScript. So you can search online on that first. Once you get the JavaScript working, you can then call back into .NET from your JavaScript code and do whatever you need to do in .NET code. You would need to use our "JavaScript extension" feature to do so: https://www.essentialobjects.com/doc/webbrowser/advanced/jsext.aspxThanks!
|
|
Rank: Newbie Groups: Member
Joined: 9/16/2015 Posts: 6
|
I've tried JS MutationObserver. I think that's the right way to go. MutationObserver on body. I've for a very specialized case gotten that approach to work previously with a two-way PropertyChanged-thing HTML<->WPF. That, however, relied on knowing what the elements are have for a prefix and have them call a known function. I think in this case, I'd like to take any HTML document, load it, inject a hook to listen to changes in the DOM, and have it forward the changes to my listener in the WPF app. I.e. I want to load a document. Then I want to append to that document a piece of JS, and have my WPF (like via ObjectForScripting) listen to notifications from that JS. I'm having no luck with it, but if somebody else has had better luck, I'm all ears!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,221
|
MutationObserver is the right direction --- however if you do not see what you need online elsewhere, then it probably does not exist. The general rule is whatever you want to do inside your page you would need to do it with JavaScript. So if you can find the correct JavaScript code/object to do it, then it can be done. If you can not, then it can not be done. Our product provides the "bridge" between the JavaScript world and the .NET world. It does not modify or add feature to the browser engine.
|
|