javascript - JApplet 根据 javascript 中 HTML 中的窗口宽度和高度设置宽度和高度

标签 javascript html japplet

我是新人,这可能是一个简单的修复。我目前正在使用 javascript 获取窗口高度和宽度,并希望使用 javascript 变量设置小程序的高度和宽度。

这是我的代码:

<html>
<title>Applet</title>
<head>

<script type="text/javascript">
var winW = 630, winH = 460;
if (document.body && document.body.offsetWidth) {
 winW = document.body.offsetWidth;
 winH = document.body.offsetHeight;
}
if (document.compatMode=='CSS1Compat' &&
    document.documentElement &&
    document.documentElement.offsetWidth ) {
 winW = document.documentElement.offsetWidth;
 winH = document.documentElement.offsetHeight;
}
if (window.innerWidth && window.innerHeight) {
 winW = window.innerWidth;
 winH = window.innerHeight;
}
</script>


</head>
<body>
<script type="text/javascript">
document.writeln('Window width = '+winW);
document.writeln('Window height = '+winH);
</script>
<applet code="applet.class" 
        archive="applet7.jar, collections-generic-4.01.jar, colt-1.2.0.jar, jung-api-2.0.1, neo4j-kernel-1.6.M01.jar, blueprints-core-1.1.jar, jung-visualization-2.0.1.jar, jung-algorithms-2.0.1.jar, jung-3d-2.0.1.jar, jung-jai-samples-2.0.1.jar, jung-3d-demos-2.0.1.jar, jung-samples-2.0.1.jar, jung-io-2.0.1.jar, jung-graph-impl-2.0.1.jar, jung-jai-2.0.1.jar, blueprints-graph-sail-1.1.jar, blueprints-dex-graph-1.1.jar, blueprints-neo4j-graph-1.1.jar, blueprints-graph-jung-1.1.jar, blueprints-neo4jbatch-graph-1.1.jar, blueprints-sail-graph-1.1.jar, blueprints-orient-graph-1.1.jar, collections-generic-4.01.jar, blueprints-rexster-graph-1.1.jar, jta.jar, lucene-core-3.1.0.jar, neo4j-lucene-index-1.6.M01.jar, neo4j-remote-graphdb-0.8-1.2.M06.jar"
        width="1300" height="700">

</applet>

</body>
</html>

我想要代码:width="1300" height="700"为:宽度=winW高度=winH。我希望将变量值赋予 <applet> 中的宽度和高度标签。

有人可以告诉我该怎么做吗?

如果我需要澄清,请告诉我。

最佳答案

一种方法是在 document.writeln() 中编写小程序,如下所示...

document.writeln('<applet code="Dummy.class" width="'+winW+'" height="'+winH+'">');

关于javascript - JApplet 根据 javascript 中 HTML 中的窗口宽度和高度设置宽度和高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9689592/

相关文章:

javascript - 常量应用程序 : () => React$Node = () => {. ..} : what does it mean this instruction?

css - 当涉及到图层时显示元素

java - 在 eclipse 中运行 JApplet

java - 重新调整大小以在java中的JApplet屏幕上显示所有文本

javascript - Django下拉[onChange]框包含选定的值但无法获取选定的值

javascript - 对使用 d3.js 的 SVG 样式感到困惑

javascript - 如何用div做一个移动循环

html - 如何在我的 Django 应用程序中为我的图像添加动画?

java - 阻止小程序闪烁

javascript - Leaflet.Draw矩形的坐标