Ciao a tutti,
come da titolo ho realizzato (prendendo spunto qua e là) uno script per il fade in/out di immagini che funziona bene su FF e IE. Il problema nasce però con Opera, pare essere totalmente incompatibile con tale browser.
Potete darmi una mano?
Grazie in aticipo.codice:var browserdetect = null; var opacity = null; var timerID = new Array(); var listaBottoni = new Array(); var delay = 75; function increaseOpacity(image){ obj = image; clearTimer(obj.src); setOpacity(obj,0); timerID[obj.src] = setInterval("fade(obj,1)",delay); } function decreaseOpacity(image){ obj = image; clearTimer(obj.src); setOpacity(obj,opacity); timerID[obj.src] = setInterval("fade(obj,0)",delay); } function setOpacity(obj,value) { if ( browserdetect == "mozilla" ) obj.style.MozOpacity = value/100; else if ( browserdetect == "ie" ) { obj.style.cssText = "filter:alpha(opacity="+opacity+");"; obj.filters[0].opacity = value; } } function clearTimer(_index){ for (i = 0; i < listaBottoni.length; i++) { if ( listaBottoni[i].src != _index ) setOpacity(listaBottoni[i],opacity); } for ( var index in timerID ) { if ( timerID[index] ) clearInterval(timerID[index]); } } function fade(obj,in_out){ if ( in_out == 1 ) { if ( browserdetect == "mozilla" && obj.style.MozOpacity < 1 ) obj.style.MozOpacity = Math.min(parseFloat(obj.style.MozOpacity)+0.1, (opacity/100) ); else if ( browserdetect == "ie" && obj.filters[0].opacity < opacity ) { obj.filters[0].opacity += 10; } else clearTimer(obj.src); } else { if ( browserdetect == "mozilla" && obj.style.MozOpacity > 0 ) obj.style.MozOpacity = Math.max(parseFloat(obj.style.MozOpacity)-0.1, 0.00); else if ( browserdetect == "ie" && obj.filters[0].opacity > 0 ) { obj.filters[0].opacity -= 10; } else clearTimer(obj.src); } } window.onload = function() { opacity = 55; node = document.getElementsByTagName('body'); listaBottoni = getElementsByClass('bottone',node[0],'img'); if ( listaBottoni.length > 0 ) browserdetect = ( listaBottoni[0].filters ) ? "ie" : ( typeof listaBottoni[0].style.MozOpacity == "string" ) ? "mozilla" : ""; for (i = 0; i < listaBottoni.length; i++) { listaBottoni[i].src = 'b_1'+(i)+'.gif'; setOpacity(listaBottoni[i],opacity); } } function getElementsByClass(searchClass,node,tag) { var classElements = new Array(); if ( node == null ) node = document; if ( tag == null ) tag = '*'; var els = node.getElementsByTagName(tag); var elsLen = els.length; var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); for (i = 0, j = 0; i < elsLen; i++) { if ( pattern.test(els[i].className) ) { classElements[j] = els[i]; j++; } } return classElements; }![]()

) uno script per il fade in/out di immagini che funziona bene su FF e IE. Il problema nasce però con Opera, pare essere totalmente incompatibile con tale browser.
Rispondi quotando
