ajax / 处理 java applet - 如何动态地将 applet 添加到页面
我使用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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是
runApplet
函数的一个已知问题。一种替代方法是:deployJava.js
(通过将其添加到页面中,然后编写新函数)getApplet
或getAppletElement
> 基本上模仿了runApplet
的作用,但不是将其写入文档,而是将其附加到(并将其作为)String
返回。String
。This is a known issue with the
runApplet
function. One alternative is to:deployJava.js
(by adding it into your page, then writing a new function)getApplet
orgetAppletElement
that basically mimics whatrunApplet
does, but instead of writing it to the document, appending it to (and returning it as) aString
.String
.我最终为此移植到了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