Here is the code so far (it's kinda sloppy at the moment, and I intend to remove the dependancy on the clear gif by making it a <span> instead of an <img>, but I have to make sure the behavior isn't too different (tilte, alt and other stuff might not work in a <span> without extensive workarounds)).
Code: Select all
function AlphaImage(src) {
// set the location of the clear gif here.
clearGif = 'dot_clr.gif';
// these are the attributes' names, I'd like to find a better way to do this,
// like take them from the arguments, but I don't know how at the moment.
attributes = new Array('null','width','height','alt','title','border','class');
// begin outputting the image
document.write('<img src="' + src);
// output the attributes
for (i=1; i < AlphaImage.arguments.length; i++) {
if (AlphaImage.argumentsїi]) {
document.write('" ' + attributesїi] + '="' + AlphaImage.argumentsїi]);
}
}
// if document.body.filters is an object, assume that the AlphaImageLoader filter is present
// (I'd like to test for the specific filter, but it doesn't seem to work. I'll make a work-around
// for IE 4 and 5 later) If it is output the necessary style sheet rule and change the src of the
// image to clearGif.
if (typeof document.body.filters == "object") {
document.write('" style="FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader( src=' + src + ', sizingmethod=scale )">');
// here I define the imagePath (the path that will lead to the src propertie) and the
// other properties of the image. I'd like to get the poperties all on the same branch
// but I can't set the properties individually for some reason (it takes the value and
// not the path).
this.properties = document.imagesїdocument.images.length-1];
this.image = this.properties.filters.item("DXImageTransform.Microsoft.AlphaImageLoader");
// set the src of the image to clearGif to make it see through so the style can show through
document.imagesїdocument.images.length-1].src = clearGif;
} else {
// make dom implementation match IE.
document.write('">');
this.properties = document.imagesїdocument.images.length-1];
this.image = this.properties;
}
}
// AlphaImage swap Image Method
AlphaImage.prototype.swapSrc = function(newSrc) {
this.image.src = newSrc;
}I'd like to be able to set "this.src" to "this.properties.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src" but when I do that it takes the value of the filter.src and assignes that to "this.src".
Is there anyway to get "this.src" to point to "this.properties.filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src" instead of taking its value?