我正在开发一个旧的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的信息。
只需插入兼容性层或jQuery 1.x的Mootools,让库找出它。如果你还不知道什么'document.all',你不会在任何地方很快成功完成这个任务。 –
我知道document.all来自DOM API,但是我不会发现它是否已经过时,如果它已经过时,我可以替换它。我没有找到关于这个的文档,所以我不知道document.all返回。 – eromjo
'all'从来不是JavaScript功能,而是Microsoft特定的JScript功能;还有:“all”不再被支持。从Internet Explorer 11开始,使用'getElementById'“。请参阅:https://msdn.microsoft.com/en-us/library/ms537434(v=vs.85).aspx由于IE8也知道'getElementBy ...'函数,你应该使用这些 – feeela