Java applet DOM 操作示例?
我希望编写我的第一个 Java 小程序(有所不同)。我想编写一个小程序来操作该小程序所在页面的 DOM。一个合适的例子将展示如何:
- 从 DOM 中检索元素(通过名称、id 或其他一些 CSS 属性)
- 将元素插入/删除到 DOM 中(在给定 DOM 元素之前/之后)
innerHTML DOM 元素的属性可以更改
调用 javascript 函数并将数据从 Java applet 传递到 javascript 函数
我已经在互联网上进行了搜索 - 但到目前为止,还没有遇到任何这样的例子。有人知道这样的例子吗?如果是,请发布一个链接或一个片段,以显示如何实现上面列出的功能(如果可能)。
I am looking to write my first Java applet (with a difference). I want to write an applet that manipulates the DOM of the page in which the applet is placed. A suitable example would show how:
- an element can be retrieved from the DOM (by name, id or some other CSS property)
- Insertion/deletion of an element in to the DOM (before/after) a given DOM element
the innerHTML of a DOM element can be changed
Call a javascript function and pass data from the Java applet, to the javascript function
I have searched the internet - but so far, have not come accross any such example. Is anyone aware of such an example?. If yes, please post a link, or a snippet that shows how to achieve the functionality listed above, if possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
www.java2s.com 始终是寻找示例的良好起点。
http://www.java2s.com/Code/JavaScript/Development/UsingJavaScriptinanApplet.htm
www.java2s.com is alsways a good starting point to look for examples.
http://www.java2s.com/Code/JavaScript/Development/UsingJavaScriptinanApplet.htm
我建议你只解决 4 并使用 JavaScript 来进行 DOM 操作。请参阅 JSObject
I'd suggest that you just solve 4 and use JavaScript to do you DOM manipulation. See JSObject