Java小程序的部署工具包:如何在没有安装JVM的情况下避免重定向
Deployment Toolkit for Java applets: how to avoid the redirect when no JVM is installed
我已经创建了一个小程序;它是使用如下部署工具包部署的(URL是假的):
<script type="text/javascript"
src="https://www.java.com/js/deployJava.js"></script>
<script>
var attributes = {
code:'br.com.brandizzi.adam.applet.MyApplet.class',
archive:'http://adam.brandizzi.com.br/html/applet.jar',
width : 50,
height : 1
};
var parameters = {
fontSize : 1,
};
var version = '1.6';
deployJava.runApplet(attributes, parameters, version);
</script>
它运行良好。然而,幸运的是,我通过一台没有JVM的机器访问了我的网站,它总是被重定向到http://www.java.com-如文件所述:
如果客户端没有所需的JRE软件的最低版本,则部署工具包脚本会将浏览器重定向到http://www.java.com以允许用户下载最新的JRE软件。在某些平台上,用户可能会在查看包含小程序的网页之前被重定向。
有没有办法避免这种重定向?页面在没有JVM的情况下可以很好地工作,小程序只是一点改进。无论如何,我们的用户可能会对这种重定向感到非常困惑,他们甚至没有安装JVM的权限。
如果你看一下deployJava.js脚本,runApplet函数会说:
/** * Ensures that an appropriate JRE is installed and then runs an applet. * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum * JRE version necessary to run this applet. minimumVersion is optional, * defaulting to the value "1.1" (which matches any JRE). * If an equal or greater JRE is detected, runApplet() will call * writeAppletTag(attributes, parameters) to output the applet tag, * otherwise it will call installJRE(minimumVersion + '+').
所以如果你打这样的
deployJava.runApplet(attributes, parameters, null);
或者像这个
deployJava.runApplet(attributes, parameters, 'undefined');
或者像这个
deployJava.runApplet(attributes, parameters, '1.1');
它只会检查是否安装了,然后重定向到Java.com进行安装。既然你有一个小程序,你就需要Java:)
或者,您可以调用deployJava.writeAppletTag(属性、参数)directy:
/** * Outputs an applet tag with the specified attributes and parameters, where * both attributes and parameters are associative arrays. Each key/value * pair in attributes becomes an attribute of the applet tag itself, while * key/value pairs in parameters become <PARAM> tags. No version checking * or other special behaviors are performed; the tag is simply written to * the page using document.writeln(). * * As document.writeln() is generally only safe to use while the page is * being rendered, you should never call this function after the page * has been completed. */
使用部署工具包的全部意义在于,如果用户没有JVM,它会提示用户安装JVM,以便您的小程序可以运行。如果您不希望它们被提示,那么就不要使用部署工具包。
如果他们已经安装了合适的JVM,那么小程序就会运行。如果没有,则页面的其余部分应正常加载。
您可以使用deployJava.js.
getJREs
函数
相关文章:
- 可以前端maven插件使用节点,npm已经安装
- 在Meteor项目中安装并包含npm模块后出错
- 无法安装节点sass相关性
- 键入环境安装不起作用
- 全局安装gull后出错
- 如何检测安装在firefox4.6ubuntu上的扩展
- Bowerrc后安装挂钩不工作
- 有没有一种方法可以从Javascript检测特定的应用程序是否安装在(AndroidiOS)设备上
- 如何安装Jasmin:Velocity项目上的javascript测试工具
- 如何从mac上完全删除Ionic和Cordova安装
- JavaScript jvm implementation
- 角度highchart ng安装
- 如何检测是否未安装在鼠标上
- Babel/Mocha:Mocha已全局安装,但未定义describe()
- 通过Nuget安装Angular JS和Angular JS核心有什么区别
- 在Strongloop中发送推送通知时,设备从安装中删除
- YouTube插件的安装是CKDior
- Chrome扩展弹出式安装
- 如何使用 JavaScript 知道安装的 JVM 是 32 位还是 64 位
- Java小程序的部署工具包:如何在没有安装JVM的情况下避免重定向