问题
I want to use some kind of webbrowser object in java to navigate to an Ajax page and
(a) add a listener to a DOM element that fires every time the HTML is changed dynamically by the server
or
(b) inject Javascript into the DOM to fire a custom event or call a Java method via an external interface or something.
Any suggestions on components that might do this, please? Any component that merely displays the page being navigated to and captures user click event is no good, unfortunately.
I need to fire events when the HTML in the DOM changes. .
Thanks.
回答1:
You can checkout the SWTBrowser component. It can be embedded within a SWT component (and hence accessed using Java) and lets you inject Javascript and do anything else.
http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fapi%2Forg%2Feclipse%2Fswt%2Fbrowser%2Fpackage-summary.html talks about this.
来源:https://stackoverflow.com/questions/8185732/embedded-headless-browser-in-java-that-supports-custom-dom-events-or-injecting-j