我的页面上有一个 JavaScript 代码,假设在单击图像时会加载 Java Applet。
它在 Chrome 上运行良好。当我在 Firefox 上加载同一页面时,它会使浏览器崩溃。
以下是片段:
Javascript
<script type="text/javascript">
var appletTag;
hideApplet(); // replace applet with clickable image
var pic2 = new Image(703,421); // preload mouse over image
pic2.src = "pic2.png";
function hideApplet() {
var appletbox = document.getElementById('appletbox');
appletTag = appletbox.innerHTML;
if (navigator.appName == 'Microsoft Internet Explorer') {
var params = "";
var p = appletbox.getElementsByTagName("PARAM");
for (var i = 0; i < p.length; i++) {
params += p[i].outerHTML;
}
appletTag = appletTag.replace("</APPLET>", params+"</APPLET>");
}
appletbox.innerHTML = '<img src="gray.png" name="pic1"
width="703" height="421"
style="cursor:pointer;background-color:gray;"
onMouseOver="mouseOverImage()"
onMouseOut="mouseOutsideImage()"
onclick="showApplet()">';
}
function showApplet() {
var appletbox = document.getElementById('appletbox');
appletbox.innerHTML = appletTag;
}
function mouseOverImage() {
document.images.pic1.src = pic2.src;
}
function mouseOutsideImage() {
document.images.pic1.src = "pic1.png";
}
</script>
和调用这个的divbox:
<div id="appletbox" style="width:703px;height:421px;">
<applet code="TestApplet.class" codebase="."
width="703" height="421">
</applet>
谁能帮我一把?提前致谢。