ajax / 处理 java applet - 如何动态地将 applet 添加到页面

发布于 2024-12-15 09:48:33 字数 717 浏览 0 评论 0原文

我使用Processing创建了一个.jar java小程序。我希望能够将 applet 动态嵌入到我的页面中,但我目前正在做的是将整个当前页面替换为 java applet,而不是将其附加到预定义的 DOM 容器中。这是我的代码:

var $projContainer = $('#project_container');

var attributes = {
    codebase:'http://java.sun.com/update/1.6.0/jinstall-6u20-windows-i586.cab',
        code:'tree',
        archive: projFile,
        width: '680', 
        height: '360'
};

var parameters = {archive: projFile, code: 'tree', scriptable: 'true', image: '/images/structure/processing_loading.gid', boxMessage: 'Loading...', boxbgcolor: '#FFFFFF'};
var version = '1.5' ; // JDK version
deployJava.runApplet(attributes, parameters, version); //Want to be able to specify a dom element to deploy to here

I created a .jar java applet with Processing. I want to be able to dynamically embed the the applet onto my page, but what I'm doing is currently replacing my entire current page with the java applet, rather than appending it in a predefined DOM container. Here's my code:

var $projContainer = $('#project_container');

var attributes = {
    codebase:'http://java.sun.com/update/1.6.0/jinstall-6u20-windows-i586.cab',
        code:'tree',
        archive: projFile,
        width: '680', 
        height: '360'
};

var parameters = {archive: projFile, code: 'tree', scriptable: 'true', image: '/images/structure/processing_loading.gid', boxMessage: 'Loading...', boxbgcolor: '#FFFFFF'};
var version = '1.5' ; // JDK version
deployJava.runApplet(attributes, parameters, version); //Want to be able to specify a dom element to deploy to here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

别忘他 2024-12-22 09:48:33

我正在做的事情是用 java applet 替换我的整个当前页面..

这是 runApplet 函数的一个已知问题。一种替代方法是:

  • 扩展 deployJava.js(通过将其添加到页面中,然后编写新函数)
  • 添加新函数 getAppletgetAppletElement > 基本上模仿了 runApplet 的作用,但不是将其写入文档,而是将其附加到(并将其作为)String 返回。
  • 按照您的意愿,使用String

what I'm doing is currently replacing my entire current page with the java applet..

This is a known issue with the runApplet function. One alternative is to:

  • Extend deployJava.js (by adding it into your page, then writing a new function)
  • Add a new function getApplet or getAppletElement that basically mimics what runApplet does, but instead of writing it to the document, appending it to (and returning it as) a String.
  • Do as you will, with the String.
丢了幸福的猪 2024-12-22 09:48:33

我最终为此移植到了processing.js,它通过 AJAX 加载没有问题。

我在这里放置了该过程的教程,因为人们就此联系我:

http ://mikeheavers.com/index.php/site/code_single/load_processing.js_sketch_with_ajax_on_user_click

I ended up porting to processing.js for this, which has no problems with being loaded via AJAX.

I put a tutorial for that process up here, since people were contacting me about it:

http://mikeheavers.com/index.php/site/code_single/load_processing.js_sketch_with_ajax_on_user_click

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文