Safari 及其他版本上的 Java Applet z-index

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/638886/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 13:10:24  来源:igfitidea点击:

Java Applet z-index on Safari and beyond

javahtmlappletoverlayz-index

提问by jwl

A well known problem with Java Applets in webpages is that browsers ignore the z-index of the applet tag vs. other components in the page. No matter how you position and z-index elements in the page, applets will draw themselves on top of everything.

网页中 Java Applet 的一个众所周知的问题是浏览器会忽略 Applet 标签与页面中其他组件的 z-index。无论您如何在页面中定位和 z-index 元素,applet 都会在所有内容之上绘制自己。

There is a workaround, known as the iframe shim, as described here: http://www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/.

有一种解决方法,称为 iframe 垫片,如下所述:http: //www.oratransplant.nl/2007/10/26/using-iframe-shim-to-partly-cover-a-java-applet/

However, this workaround does not work in Safari 3 or 4 in Windows (assuming the same for Mac).

但是,此解决方法不适用于 Windows 中的 Safari 3 或 4(假设 Mac 相同)。

Does anyone know a way to make it work in Safari?

有谁知道让它在 Safari 中工作的方法?

Does anyone have ideas about how to pressure Sun to fix the underlying problem so we can avoid clumsy shims? Here is a bug report on the issue, http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6646289, notice that it has been open for a year, however other bug reports go back many many years.

有没有人知道如何向 Sun 施压以解决潜在问题,以便我们避免笨拙的垫片?这是关于这个问题的错误报告,http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6646289,注意它已经开放了一年,但是其他错误报告可以追溯到很多年前。

This is so frustrating, don't Sun understand that this is the very sort of thing that has marginalized Java as a way of doing cool stuff in the browser? I love you Java, but you are not helping your situation...

这太令人沮丧了,难道 Sun 不明白这是一种将 Java 边缘化为在浏览器中做很酷东西的方式的事情吗?我爱你 Java,但你没有帮助你的情况......

采纳答案by Kornel

Actually problem is not related to z-index at all. It's caused by "windowed" drawing model of Netscape Plugin API (NPAPI).

实际上问题根本与 z-index 无关。它是由 Netscape Plugin API (NPAPI) 的“窗口化”绘图模型引起的。

You can't do anything about it (except the shim). Plugin author has to rewrite it using windowless API.

你对此无能为力(除了垫片)。插件作者必须使用 windowless API 重写它

回答by sandeep parkhande

There is a tricky solution for the problem. It's not necessary to have the code inside an iframe. We can have a dummy iframejust as a layer above the applet. And then an absolute div with the text can easily placed above that iframe.

这个问题有一个棘手的解决方案。没有必要将代码放在iframe. 我们可以有一个虚拟iframe作为小程序上方的一层。然后一个带有文本的绝对 div 可以很容易地放在它上面iframe

working example

工作示例

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Applet z index issue</title>
<style>

.applet {width:400px; margin:0 auto; text-align:center; border:1px solid #000; left:40%; position:absolute }
.iframe {width:400px;  background:#fff; position:absolute; border:1px solid #f00; position:absolute; left:45%; top:20px; z-index:9; height:201px;}
.message { width:250px; border:1px solid #000; background:#fff; height:150px; color:#fff; text-align:center;  z-index:99; background:#555;  float:left; position:absolute; left:45%; top:20px}

 </style>
</head>

<body>
<div class="message">Message</div>
<div class="iframe"><iframe style="width:500px; height:205px; background:none; border:none"> </iframe></div>
<div class="applet">

<applet code="Bubbles.class" width="400" height="350">
Java applet that draws animated bubbles.
</applet>

</div>

</body>
</html>

回答by gbvb

For one, Java on Mac is actually built by Apple and not Sun. As for the applets, we hide the applets when there is something appearing on top of it. That might not suffice for your needs though.

一方面,Mac 上的 Java 实际上是由 Apple 而不是 Sun 构建的。至于小程序,当有东西出现在小程序之上时,我们将小程序隐藏起来。但这可能不足以满足您的需求。