我在我的
HTML页面嵌入iframe元素:
<iframe src="applet.html" frameborder="0" style="width: 600px; height: 600px;"></iframe>
applet.html看起来像这样:
<html> <head> </head> <body> <applet code="ClockApplet.class" width="100%" height="100%"> </applet> </body> </html>
问题是:如何在iframe中的Java小程序上显示一个div元素(位置:absolute).
我试图使用另一个iframe元素:
<html> <head> </head> <body> <iframe src="applet.html" frameborder="0" style="width: 600px; height: 600px;"></iframe> <iframe src="javascript:false;" frameborder="0" style="position: absolute; top: 10px; left: 10px; width: 150px; height: 150px; z-index: 99"></iframe> <div style="position: absolute; top: 10px; left: 10px; background-color: gray; height: 150px; width: 150px; z-index: 100">Hello World</div> </body> </html>
在IE浏览器中可以正常工作,而不是Chrome.
解决方法
我发现一篇文章似乎提供了一个解决方案,所以我不会要求提供这样的信用:
http://www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/
从文章:
The solution is to have a third Iframe
C within Iframe A. Iframe C has a
z-index within Iframe A that is higher
than the z-index of the Applet. It is
positioned so that it’s rectangle as
considered by the top page is
identical to that of the Iframe B
overlay.
我将第二个IFrame代码从主页粘贴到applet.html中,如下所示:
<iframe src="javascript:false;" frameborder="0" style="position: absolute; top: 10px; left: 10px; width: 150px; height: 150px; z-index: 1"></iframe> <applet code="ClockApplet.class" width="100%" height="100%"> </applet>
而且它似乎是在Chrome中做的伎俩.
我确实获得了框架边框,但我猜这是可以固定的.搏一搏.