新的 Chrome 更新阻止了 Java;我怎样才能等到获得许可后再调用我的小程序的代码?

发布于 2024-11-04 05:39:22 字数 479 浏览 0 评论 0原文

最近,Chrome 获得了新更新它会自动阻止所有插件。它会出现一个栏,询问用户是否允许启用它。 这就是栏的样子。

我的网站有一个按钮,单击该按钮后会加载 Java 小程序并调用其中的方法。问题在于,它尝试在小程序加载后立即调用该方法,然后才能授予权限。当然,这会给我的 Javascript 带来一个错误,说没有这样的方法。

我怎样才能告诉我的按钮等到小程序被授予权限后再调用它的方法?我无法预加载小程序,因为它是自签名的,并且我不希望在需要时弹出安全对话框。通常,该对话框会暂停 Javascript,并在授予或拒绝访问时恢复它,但这个新的 Chrome 对话框与站点并行运行。

Recently, Chrome got a new update which blocks all plug-ins automatically. It makes a bar appear asking the user for permission to enable it. This is what the bar looks like.

My site has a button that when clicked, loads a Java applet and calls a method inside it. The problem is that it tries to call the method immediately after the applet is loaded, before permission can be granted. Naturally, this gives me an error in my Javascript saying that there is no such method.

How can I tell my button to wait until the applet has been granted permission before calling its methods? I can't preload the applet because it's self-signed and I don't want the security dialog box to pop up until it's needed. Normally that dialog box pauses the Javascript and resumes it when access has been granted or denied, but this new Chrome dialog runs in parallel to the site.

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

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

发布评论

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

评论(1

梦幻的味道 2024-11-11 05:39:22

一旦成功加载,您就可以让您的 Applet 调用 Javascript 方法。然后,您的 Javascript 将等待该方法被调用,然后再尝试访问 Applet。

对于 Java 到 Javascript 的通信,您有几个选择。您可以在 Google 中搜索 JSObject 类,尽管我的理解是这需要特定于浏览器的二进制文件,因此可能不是一个可行的解决方案。更简单的方法是使用 AppletContextshowDocument 方法来执行 Javascript,如 http://www.brilliantsheep.com/java-to-javascript-communication-made-simple/

例如,在 Applet 的 init() 方法中,您将具有如下所示的代码:

getAppletContext().showDocument( "javascript:onAppletIsReady()", "_self" );

然后只需在 javascript 中定义一个名为 onAppletIsReady 的方法,该方法在 Applet 加载后立即执行您之前运行的任何逻辑。

You could have your Applet call a Javascript method once it has successfully loaded. Your Javascript would then wait for this method to be called before attempting to access the Applet.

For Java-to-Javascript communication you have a couple of options. You could search Google for the JSObject class, although my understanding is that this requires browser-specific binaries and so may not be a workable solution. What is easier is just using the AppletContext's showDocument method to execute Javascript, as described at http://www.brilliantsheep.com/java-to-javascript-communication-made-simple/.

In your Applet's init() method, for example, you would have code like the following:

getAppletContext().showDocument( "javascript:onAppletIsReady()", "_self" );

And then just define a method called onAppletIsReady in your javascript that executes whatever logic you were previously running as soon as the Applet was loaded.

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