2012-11-15 31 views
0

我有一些java腳本來檢查applet是否在加載頁面的其餘部分之前完成加載。它已經工作了多年,現在似乎在Firefox 16和IE 7中失敗。它在IE 8中工作文件。 <applet name> .isAlive()在某些瀏覽器中失敗

有關它爲什麼會崩潰以及可能會修復它的任何建議?

<applet name="env" archive="portal-applet-envir.jar" code="com/deleted/AppletEnvironment.class" height="1" mayscript="true" width="1"> 
</applet> 
<table width="98%" align="center"><tr><td> 
<script language="javascript"> 
function waituntilok() { 
    if (document.env.isActive()) { 
    doit(); 
    } 
    else { 
     var ct = 0; 
     while (! document.env.isActive()) 
     { 
     } 
    doit(); 
    } 
} 
[....] 
waituntilok(); 
</script> 
</td></tr></table> 
+0

1)通過'waituntilok()'的外觀,它會循環直到'document.env.isActive()'。它會進入無限循環嗎? 2)'code =「com/deleted/AppletEnvironment.class」'應該是'code =「com.deleted.AppletEnvironment」'。 –

+0

當applet最終加載時,循環終止。 代碼參數一直工作到最近。我是否依賴於某個功能? – Aaron

+0

不知道。 if(document)'&if(document.env)'的結果是什麼?彈出提醒或向頁面寫入內容。應該'name'是'id'? –

回答

1

當Applet被初始化之前document.env.isActive()被調用時,FF寄存器A「沒有這樣的方法」的錯誤並退出功能。在調試這些事情時,檢查錯誤控制檯會付出代價。

另外可疑的是1x1的小程序大小。有些工具旨在保護用戶,將刪除「可疑的小」HTML元素。

此版本在FF中工作。在IE & FF中試用並回報。

<html> 
<body> 
<applet 
    name="env" 
    archive="http://pscode.org/lib/mime.jar" 
    code="org.pscode.mime.MimeType" 
    height="100" 
    mayscript="true" 
    width="600"> 
</applet> 
<table width="98%" align="center"> 
<tr> 
<td> 
<script language="javascript"> 
function waituntilok() { 
    if (document) { 
     alert('document'); 
    } 
    if (document.env) { 
     alert('document.env'); 
    } 
    if (document.env.isActive()) { 
     doit(); 
    } else { 
     var ct = 0; 
     while (! document.env.isActive()) 
     { 
     } 
     doit(); 
    } 
} 

function doit() { 
    alert('Just Do It!'); 
} 

setTimeout('waituntilok()', 15000); 
</script> 
</td> 
</tr> 
</table> 
</body> 
</html> 
+0

我沒有看到日誌中沒有這種方法錯誤。我應該報告它。 – Aaron

+0

1x1大小是故意的,我正在使用小程序來收集我在javascript函數中使用的一些信息,但用戶不應該看到任何東西。 – Aaron

+0

*「1x1大小是故意的」* O_o告訴我一些***不是明顯的明顯。 –

相關問題