Vampire
30-11-2005, 00:29
Есть такой вот скриптец:
<!--
// Returns the closest parent tag with tagName containing
// the src tag. If no such tag is found - null is returned.
function checkParent( src, tagName ) {
while ( src != null ) {
if (src.tagName == tagName)
return src;
src = src.parentElement;
}
return null;
}
// Returns the first tag with tagName contained by
// the src tag. If no such tag is found - null is returned.
function checkContent( src, tagName ) {
var pos = src.sourceIndex ;
while ( src.contains( document.all[++pos] ) )
if ( document.all[pos].tagName == tagName )
return document.all[pos] ;
return null ;
}
// Handle onClick event in the outline box
function outlineAction() {
var src = event.srcElement ;
var item = checkParent( src, "DT" ) ;
if ( parent != null ) {
var content = checkContent( item, "DL" ) ;
if ( content != null )
if ( content.style.display == "" )
content.style.display = "block" ;
else
content.style.display = "" ;
}
event.cancelBubble = true;
}
// -->
А вот тут он применяется:
<DIV onClick="JavaScript: outlineAction();">
<dl>
<!--Text-->
<dt class="oParent">Боевые отравляющие вещества<dl>
<dt class="oItem"><a href="poison/po01/po0002.html" class="m"><span class="q">Адамсит (DM)</a></dt>
<dt class="oItem"><a href="poison/po01/po0003.html" class="m"><span class="q">Ви-Икс газ (VX)</a></dt>
<dt class="oItem"><a href="poison/po01/po0004.html" class="m"><span class="q">Дифенилхлорарсин (DA) </a></dt>
<dt class="oItem"><a href="poison/po01/po0005.html" class="m"><span class="q">Дифенилцианарсин (DC)</a></dt>
<dt class="oItem"><a href="poison/po01/po0006.html" class="m"><span class="q">Дифосген (CG2)</a></dt>
<dt class="oItem"><a href="poison/po01/po0001.html" class="m"><span class="q">Зарин</a></dt>
<dt class="oItem"><a href="poison/po01/po0007.html" class="m"><span class="q">Зоман (GD)</a></dt>
<dt class="oItem"><a href="poison/po01/po0008.html" class="m"><span class="q">Люизит (L)</a></dt>
</dl></dt>
<dt class="oParent">Бытовые отравляющие вещества<dl>
<dt class="oItem"><a href="poison/po02/po0001.html" class="m"><span class="q">Уксусная кислота</a></dt>
<dt class="oItem"><a href="poison/po02/po0002.html" class="m"><span class="q">Хлорциан</a></dt>
</dl></dt>
<!--/Text-->
</dl>
</DIV>
Скрипт отвечает за структурированные списки с сылками. Позволяет разворачивать/сворачивать списки.
В эксплорере скрипт просчитывается без проблем, а вот в Mozilla Firefox возникают проблемы в 27 строчке скрипта (var src = event.srcElement ;). В чем трабл и как его можно разрешить?
ЗЫ: применение скрипта можно глянуть у меня на сайте http://tools-of-death.ru/poison.html
<!--
// Returns the closest parent tag with tagName containing
// the src tag. If no such tag is found - null is returned.
function checkParent( src, tagName ) {
while ( src != null ) {
if (src.tagName == tagName)
return src;
src = src.parentElement;
}
return null;
}
// Returns the first tag with tagName contained by
// the src tag. If no such tag is found - null is returned.
function checkContent( src, tagName ) {
var pos = src.sourceIndex ;
while ( src.contains( document.all[++pos] ) )
if ( document.all[pos].tagName == tagName )
return document.all[pos] ;
return null ;
}
// Handle onClick event in the outline box
function outlineAction() {
var src = event.srcElement ;
var item = checkParent( src, "DT" ) ;
if ( parent != null ) {
var content = checkContent( item, "DL" ) ;
if ( content != null )
if ( content.style.display == "" )
content.style.display = "block" ;
else
content.style.display = "" ;
}
event.cancelBubble = true;
}
// -->
А вот тут он применяется:
<DIV onClick="JavaScript: outlineAction();">
<dl>
<!--Text-->
<dt class="oParent">Боевые отравляющие вещества<dl>
<dt class="oItem"><a href="poison/po01/po0002.html" class="m"><span class="q">Адамсит (DM)</a></dt>
<dt class="oItem"><a href="poison/po01/po0003.html" class="m"><span class="q">Ви-Икс газ (VX)</a></dt>
<dt class="oItem"><a href="poison/po01/po0004.html" class="m"><span class="q">Дифенилхлорарсин (DA) </a></dt>
<dt class="oItem"><a href="poison/po01/po0005.html" class="m"><span class="q">Дифенилцианарсин (DC)</a></dt>
<dt class="oItem"><a href="poison/po01/po0006.html" class="m"><span class="q">Дифосген (CG2)</a></dt>
<dt class="oItem"><a href="poison/po01/po0001.html" class="m"><span class="q">Зарин</a></dt>
<dt class="oItem"><a href="poison/po01/po0007.html" class="m"><span class="q">Зоман (GD)</a></dt>
<dt class="oItem"><a href="poison/po01/po0008.html" class="m"><span class="q">Люизит (L)</a></dt>
</dl></dt>
<dt class="oParent">Бытовые отравляющие вещества<dl>
<dt class="oItem"><a href="poison/po02/po0001.html" class="m"><span class="q">Уксусная кислота</a></dt>
<dt class="oItem"><a href="poison/po02/po0002.html" class="m"><span class="q">Хлорциан</a></dt>
</dl></dt>
<!--/Text-->
</dl>
</DIV>
Скрипт отвечает за структурированные списки с сылками. Позволяет разворачивать/сворачивать списки.
В эксплорере скрипт просчитывается без проблем, а вот в Mozilla Firefox возникают проблемы в 27 строчке скрипта (var src = event.srcElement ;). В чем трабл и как его можно разрешить?
ЗЫ: применение скрипта можно глянуть у меня на сайте http://tools-of-death.ru/poison.html