PDA

View Full Version : Another Bug in Ultimate Fade-in slideshow (v1.5)



jens_thiel
04-07-2006, 09:56 AM
Hi there,

first one simple thing. I think that in the resetit function,


crossobj.style.KhtmlOpacity=obj.degree/100

should be:


crossobj.style.KhtmlOpacity=this.degree/100

The more serious problem is with certain IE6 settings where a check for a filter property fails with an "Unspecified error", e.g.:


if (crossobj.filters&&crossobj.filters[0]){

I can not say what settings are actually responsible, but the problem popped up previously on these forums. What I did to make it at least work without the fading effect was to create a new SetIeOpacity function:


function SetIeOpacity(crossobj,degree)
{
try
{
if (crossobj.filters&&crossobj.filters[0]&&(typeof crossobj.filters[0].opacity=="number")){ //if IE6+
crossobj.filters(0).opacity=this.degree
return
}
}
catch(e){}
if(crossobj.style.filter)
crossobj.style.filter="alpha(opacity="+degree+")"
}

and change the fadepic and resetit functions as follows:


function fadepic(obj){
if (obj.degree<100){
obj.degree+=10
if(iebrowser&&dom) // if IE5+
SetIeOpacity(obj.tempobj,obj.degree)
else if (obj.tempobj.style.MozOpacity)
obj.tempobj.style.MozOpacity=obj.degree/101
else if (obj.tempobj.style.KhtmlOpacity)
obj.tempobj.style.KhtmlOpacity=obj.degree/100
}
else{
clearInterval(fadeclear[obj.slideshowid])
obj.nextcanvas=(obj.curcanvas==obj.canvasbase+"_0")? obj.canvasbase+"_0" : obj.canvasbase+"_1"
obj.tempobj=iebrowser? iebrowser[obj.nextcanvas] : document.getElementById(obj.nextcanvas)
obj.populateslide(obj.tempobj, obj.nextimageindex)
obj.nextimageindex=(obj.nextimageindex<obj.postimages.length-1)? obj.nextimageindex+1 : 0
setTimeout("fadearray["+obj.slideshowid+"].rotateimage()", obj.delay)
}
}

fadeshow.prototype.resetit=function(){
this.degree=10
var crossobj=iebrowser? iebrowser[this.curcanvas] : document.getElementById(this.curcanvas)
if(iebrowser&&dom) // if IE5+
SetIeOpacity(crossobj,this.degree)
else if (crossobj.style.MozOpacity)
crossobj.style.MozOpacity=this.degree/101
else if (crossobj.style.KhtmlOpacity)
crossobj.style.KhtmlOpacity=this.degree/100
}

I'm not sure if IE4 and the like would still stumble over try/catch even if it is in a function that is not called on these platforms. Maybe someone more experienced with this can replace the try/catch with onerror or suggest a better solution to catch the "Unspecified error".

Best regards,
Jens.

mwinter
04-07-2006, 11:15 AM
I think that in the resetit function,


crossobj.style.KhtmlOpacity=obj.degree/100

should be:


crossobj.style.KhtmlOpacity=this.degree/100Yes, it should.


The more serious problem is with certain IE6 settings where a check for a filter property fails with an "Unspecified error", e.g.:


if (crossobj.filters&&crossobj.filters[0]){

I can not say what settings are actually responsible, but the problem popped up previously on these forums.Assuming it's the same error, I experienced that with what was essentially a broken multiple-IE installation. The DirectX libraries used by IE (v5.0, in this instance) weren't available. However, it's possible that other circumstances could cause the problem (scripting security options, for example).

A simple test that should suffice is to use the typeof operator. In the scenario above, the typeof returned an undocumented 'unknown' value. However, both the filters property, and the properties of that object, should evaluate to 'object'.

Whilst we're on the subject of this expression, it's my opinion that the filters should be accessed by name. There's no guarantee that the Alpha filter will be the only one applied to an element, nor that it will be the first in the collection.



if ((typeof crossobj.filters == 'object')
&& (typeof crossobj.filters['DXImageTransform.Microsoft.Alpha'] == 'object')) {
/* ... */
}
I'm chose to use the DirectX filter, above. However, it's quite trivial to negotiate between the two varieties to cope with IE 5.0x, for example, which can only handle the legacy version.


I'm not sure if IE4 and the like would still stumble over try/catch even if it is in a function that is not called on these platforms.Yes, it would. Function declarations are parsed as they are encountered; they have to be so that the interpreter can know what constitutes the function body, and what follows it.


Maybe someone more experienced with this can replace the try/catch with onerror or suggest a better solution to catch the "Unspecified error".The suggestion above should suffice, however the alternative is to use JScript's conditional compilation feature.

Mike

jscheuer1
04-08-2006, 06:41 PM
I had identified and fixed that first error in my more recent fix for Safari in this forum. I also had originally used a try/catch scheme for opacity tests in IE that wasn't even written unless the browser passed certain IE version specific conditional comment tests but was overruled by ddadmin, it is his script after all. :)

jens_thiel
04-11-2006, 09:02 AM
Hello Mike,

the typeof test was a good idea and I could rewrite SetIeOpacity without the try/catch:


function SetIeOpacity(crossobj,degree)
{
if((typeof crossobj.filters!='unknown')&&crossobj.filters[0]&&(typeof crossobj.filters[0].opacity=="number")) //if IE6+
crossobj.filters(0).opacity=degree
else if(crossobj.style.filter)
crossobj.style.filter="alpha(opacity="+degree+")"
}


Thanks,
Jens.