PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Tue Dec 18, 2018 7:16 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Tue Jun 18, 2002 5:51 pm 
Offline
Forum Newbie

Joined: Tue Jun 18, 2002 1:41 pm
Posts: 9
In javascript, I'm trying to create an object that will out put the necessary code for semi-transparent gif files and still have regular properties as if it where an image.

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)).

Syntax: [ Download ] [ Hide ]
function AlphaImage(src) &#123;
        // 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('&lt;img src="' + src);
       
        // output the attributes
        for (i=1; i &lt; AlphaImage.arguments.length; i++) &#123;
                if (AlphaImage.arguments&#1111;i]) &#123;
                        document.write('" ' + attributes&#1111;i] + '="' + AlphaImage.arguments&#1111;i]);
                &#125;
        &#125;
       
        // 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") &#123;
                document.write('" style="FILTER: progid:DXImageTransform.Microsoft.AlphaImageLoader( src=' + src + ', sizingmethod=scale )"&gt;');
               
                // 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&#1111;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&#1111;document.images.length-1].src = clearGif;
        &#125; else &#123;
                // make dom implementation match IE.
                document.write('"&gt;');
                this.properties = document.images&#1111;document.images.length-1];
                this.image = this.properties;  
        &#125;
&#125;

// AlphaImage swap Image Method
AlphaImage.prototype.swapSrc = function(newSrc) &#123;
        this.image.src = newSrc;
&#125;



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?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group