在 ie8 和 chrome 中从 javascript 调用 java 方法
我一直想知道是否有办法让以下 javascript 函数在 IE8 和 Chrome 中工作:
var funct = function()
{
var ppt = new java.awt.Point(200,100);
alert(ppt.x);
}
这个东西只在 Firefox 中工作。有没有办法在 IE 8 和 Chrome 中启用全局 Java 包?
I have been wondering if there is a way to make the following javascript functions work in IE8 and Chrome:
var funct = function()
{
var ppt = new java.awt.Point(200,100);
alert(ppt.x);
}
This thing works only in Firefox. Is there a way to enable global Java packages in IE 8 and Chrome?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有完全回答您的问题 - 但您可能会发现 GWT (http://code.google.com/webtoolkit/) 有帮助。
它允许您用 Java 编写 Web 应用程序,该应用程序被“编译”为 javascript,以便在任何现代浏览器中运行。它仅支持标准 Java 库的一个子集 - 特别是它不支持 java.awt。
Not quite answering your question - but you might find GWT (http://code.google.com/webtoolkit/) helpful.
It lets you write web applications in Java, which gets 'compiled' into javascript to be run inside any modern browser. It only supports a subset of the standard Java libraries - in particular it doesn't support java.awt.
嗯,就在这里。 IE 8 和 Chrome 不允许全局 java 包:
即你不能直接在 JavaScript 中使用 java.lang.String 或 java.atw.Point 。但是,如果您有一个小程序,您可以轻松地通过您的小程序公开此类。例如,如果您在小程序中导入 java.awt.Point 并具有如下方法:
public Point createPoint(int x,int y);
您现在应该能够从 javascript 访问小程序并像这样调用它的方法:
(javascript代码)
干杯
Well, here it is. IE 8 and Chrome do not allow for global java packages:
i.e you cant use java.lang.String, or java.atw.Point directly in your javascript. However, if you have an applet, you can easily expose such classes through your applet. For example, if you import java.awt.Point in your applet and have a method like this:
public Point createPoint(int x,int y);
You should be able now from your javascript to access the applet and just call its method like this:
(javascript code)
Cheers