将 Java Applet 嵌入到 .html 文件中 [英] Embedding Java Applet into .html file
问题描述
我在将小程序嵌入网页时遇到问题.我认为我做得不对.
I am having trouble embedding my applet into a webpage. I don't think I'm doing it correctly.
* 我的 html 文件和我的 .class 文件在同一个目录中
* I have my html file in the same directory as my .class files
我的主要方法在 CardApp 类中
My main method is in CardApp class
这是我的html代码
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="content-type">
<title>TestJCardBet.html</title>
</head>
<body>
<applet codebase="" code="CardApp.class" height="400" width="500"></applet>
</body>
</html>
推荐答案
让小应用程序在各种浏览器上工作出奇地困难.早期的标签没有正确标准化,因此 Internet Explorer 和 Mozilla 走向了不同的方向.
Making applets work across a wide range of browsers is surprisingly hard. The tags weren't properly standardized in the early days, so Internet Explorer and Mozilla went separate directions.
Sun 开发了一个通用 JavaScript 来处理所有特定的浏览器怪癖,因此您不必担心浏览器兼容性.
Sun developed a generic JavaScript to handle all the specific browser quirks, so that you don't have to worry about browser compatibility.
将此添加到您的 部分:
Add this to your <head>
section:
<script src="//www.java.com/js/deployJava.js"></script>
这到部分:
<script>
var attributes = {codebase: 'http://my.url/my/path/to/codebase',
code: 'my.main.Applet.class',
archive: 'my-archive.jar',
width: '800',
height: '600'};
var parameters = {java_arguments: '-Xmx256m'}; // customize per your needs
var version = '1.5'; // JDK version
deployJava.runApplet(attributes, parameters, version);
</script>
请参阅 Java™ 富 Internet 应用程序部署建议 有关脚本和所有可能选项的详细说明.
See Java™ Rich Internet Applications Deployment Advice for a detailed explanation of the script and all the possible options.
这篇关于将 Java Applet 嵌入到 .html 文件中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!