Код работает должным образом в Firefox и Chrome .
Когда страница загружается в Internet Explorer, вы получаете сообщение об ошибке
Пользовательский агент: Mozilla / 4.0 (совместимый; MSIE 8.0; Windows NT 6.1; WOW64; Trident / 4.0; GTB6.5; SLCC2; .NET CLR. 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; eSobiSubscriber 2.0.4.16; FDM; InfoPath.3) Отметка времени: среда, 18 августа 2010 г., 13:48: 54 UTC
, и когда вы нажимаете ссылку
<a href="javascript:toggleLayer('sub< ? echo $l; ?>');"><? echo $alp[$l]; ?></a>
, вы получаете сообщение об ошибке
Сообщение: Ожидаемый объект
Строка: 4
Символ: 1
Код: 0
URI:Сообщение: Требуется объект
Строка: 24
Символ: 4
Код: 0
URI:
В Firefox или Chrome нет ошибок, только IE.
Любая помощь приветствуется. Вот мой код:
function toggleLayer( whichLayer )
{
var sub=new Array();
for (i=1;i<25;i++)
{
sub[i] = 'sub'+i;
}
var elem, vis;
if( document.getElementById ) // this is the way the standards work
elem = document.getElementById( whichLayer );
else if( document.all ) // this is the way old msie versions work
elem = document.all[whichLayer];
else if( document.layers ) // this is the way nn4 works
elem = document.layers[whichLayer];
vis = elem.style;
// if the style.display value is blank we try to figure it out here
for (i=1;i<26;i++)
{
eelem = document.getElementById( sub[i] );
vvis = eelem.style;
if(eelem==elem){
vvis.display = "block";
} else {
vvis.display = "none";
}
}
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}