2015-07-21 75 views
0

我正在開發一箇舊的Web應用程序(最初爲Internet Explorer 6開發,現在升級爲Internet Explorer 8),我需要確保Mozilla Firefox和Google Chrome兼容。我設法爲Mozilla Firefox做到這一點,但Google Chrome瀏覽器比較難,菜單不顯示,我不知道爲什麼。我有這樣的代碼(這裏是主菜單,也存在類似的東西了其開發的子菜單,當你將鼠標懸停在菜單項):從Internet Explorer 6到Google Chrome

if((document.all)||(window.sidebar)){ 
     var clic=""; 
     var style=""; 
     if(this[i].url!=""){ 
      style="cursor:pointer;"; 
      clic=" onclick='window.location=\""+this[i].url+"\"'";} 
     A+="<div id='main"+i+"' style='position:absolute; left:"+X+"; top:"+Y+"; "+style+"width:130px"+/*this[i].larg+*/"; height:18px"+/*this.haut+*/"; background-color:"+colBarre+"; "+cssTexte+"; text-align:center' onmouseover='start("+i+", "+this[i].mnu+", "+X+", "+(Y+this.haut+1)+")'"+clic+">"+this[i].txt+"</div>";} 
    if(document.layers){ 
     var txt=this[i].txt; 
     if(this[i].url!=""){ 
      txt="<a href='"+this[i].url+"'>"+txt+"</a>";} 
     A+="<layer name='main"+i+"' left="+X+" top="+Y+" width=130px"+/*this[i].larg+*/" height=18px"+/*this.haut+*/" bgcolor="+colBarre+" onmouseover='start("+i+","+this[i].mnu+", "+X+", "+(Y+this.haut+1)+")'><center><span style='background-color:"+colBarre+cssTexte+"'>"+txt+"</span></center></layer>";} 
    X+=this[i].larg+1;} 

網絡我仍然在許多研究後不明白document.layers,document.all,window.sidebar,window.getElementById和document.getElementById是什麼,它們究竟返回什麼,以及window.getElementById和document.getElementById之間的區別是什麼。總結:我需要關於document.layers,document.all,window.sidebar,window.getElementById和document.getElementById的信息。

+0

只需插入兼容性層或jQuery 1.x的Mootools,讓庫找出它。如果你還不知道什麼'document.all',你不會在任何地方很快成功完成這個任務。 –

+0

我知道document.all來自DOM API,但是我不會發現它是否已經過時,如果它已經過時,我可以替換它。我沒有找到關於這個的文檔,所以我不知道document.all返回。 – eromjo

+0

'all'從來不是JavaScript功能,而是Microsoft特定的JScript功能;還有:「all」不再被支持。從Internet Explorer 11開始,使用'getElementById'「。請參閱:https://msdn.microsoft.com/en-us/library/ms537434(v=vs.85).aspx由於IE8也知道'getElementBy ...'函數,你應該使用這些 – feeela

回答

0

最後,我已經解決了我的問題。如果有人需要一個答案,在這裏我做了什麼。 document.all和document.layers都已經過時,已經使用了Internet Explorer 6.所以我使用document.getElementById而不是document.all,並在document.layer的條件下全部擦除。最後,我沒有找到document.all,window.sidebar和document.getElementById返回(編輯:這裏的答案From Internet Explorer 6 to Google Chrome),但我的應用程序在IE,MF和GC上運行良好,這就是我所需要的,所以一切正常。

相關問題