Embedded/Headless browser in Java that supports custom DOM events or injecting javascript

余生颓废 提交于 2019-12-24 11:12:58

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!