2012-04-03 69 views
2

大家下午好,“整页”applet(无javascript)的HTML代码?

我有一个Java小程序,我希望在网站上嵌入。我要求该小程序为全尺寸的,即它占据了网页的100%宽度和100%高度。

应该没有滚动条。

这是我目前拥有的代码:

<!doctype html> 
<html> 
    <body style="background:red; width:100%; height:100%; padding:0; margin:0; border:0;"> 
    <applet code="HelloWorld.class" style="padding:0; margin:0; border:0; width:100%; height:100%;"> 
     Your browser does not support the <code>applet</code> tag. 
    </applet> 
    <!-- the applet should cover the entire page, so even though the body is red, it should be covered by the applet --> 
    </body> 
</html> 

出于某种原因,它不会在Firefox和IE浏览器。在Chrome中,该小应用程序似乎是高于页面本身的,因此显示了一个垂直滚动条。我们如何使小程序填充网页的确切大小,既不显示任何水平滚动条也不显示垂直滚动条? PS:如果可能的话,在JavaScript禁用的浏览器上工作的解决方案将很酷。

回答

4

另一种方式......

applet { 
    position: absolute; 
    top: 0; 
    left: 0; 
    width:100%; 
    height:100%; 
} 
+0

您可能想要在一大堆浏览器上测试它。上次我检查它时,有很多[混合结果](http://pscode.org/test/resize/)用于使用百分比值确定applet的大小。 (使用JS部署和调整applet的大小更安全),这种类型的东西是JS擅长的。 – 2012-04-03 01:57:50

6

使用绝对位置。不要指定高度或宽度。

applet { 
    position: absolute; 
    top: 0; 
    left: 0; 
    bottom: 0; 
    right: 0; 
} 
+0

但是,这整个的一点是,我想小程序是全宽和全高.. – Pacerier 2012-04-03 01:02:51

+0

@pacerier - 这就是为什么你指定底部对。它按照你想要的方式工作。 – gilly3 2012-04-03 01:24:45

+0

我使用的是Chrome v18.0.1025.142,由于某些原因,它无法按预期工作。 – Pacerier 2012-04-03 01:27:54