Thnak you Steve.
"this.setProperty is not a function" this is the error thrown by
Firebug, and is not working anymore.

$$('.chg_src').addEvent('click', function(){
                                var image_id = this.get('id');
                                alert("the id of the image is: " + image_id);
                                $('img_container').setProperty('src', 'images/' 
+ image_id
+'.png');
                                var new_src = 
$('img_container').getProperty('src')
                                alert("the src attribute was changed: " + 
new_src);
                        })

I use this code and the last message shows also the correct 'src'
attribute. The only problem is that the new image is not displayed.
I'm thinking I should try it on IE 6 version without any limitations,
to see if it is displayed or not. Also I'm testing it on my local
machine, and not using a web server.


On May 26, 10:30 am, "Steve Onnis" <[email protected]> wrote:
> Maybe change
>
> $('img_container').setProperty('src'.....
>
> To
>
> this.setProperty('src'
>
> Steve
>
> -----Original Message-----
> From: [email protected]
>
> [mailto:[email protected]] On Behalf Of Judas Priest
> Sent: Tuesday, 26 May 2009 5:22 PM
> To: MooTools Users
> Subject: [Moo] Image change 'src' attribute - IE 6 problem
>
> Hello everybody.
>
> I have a simple piece of code, which, based on users click event, the
> 'src' attribute of an image is changed with another generated using
> the 'id' of the image element. Every thing is working just fine in all
> major browser with the exception (as many times before) IE version 6.
>
> The JavaScript code is:
> $$('.chg_src').addEvent('click', function(){
>                                 var image_id = this.get('id');
>                                 $('img_container').setProperty('src',
> 'images/' + image_id
> +'.png');
>                         });
> And the HTML code:
> <img class="left" id="img_container" src="images/nl1.png" />
> <div id="imgs_container" class="right">
>         <ul id="thumbs">
>                 <li><img class="chg_src" id="nl1" src="images/nl1_thumb.png"
> /></li>
>                 <li><img class="chg_src" id="nl2" src="images/nl2_thumb.png"
> /></li>
>                 <li><img class="chg_src" id="nl3" src="images/nl3_thumb.png"
> /></li>
>                 <li><img class="chg_src" id="nl4" src="images/nl4_thumb.png"
> /></li>
>                 <li><img class="chg_src" id="nl5" src="images/nl5_thumb.png"
> /></li>
>         </ul>
> </div>
>
> The problem is that nothing is happening in IE 6 when the thumb image
> is clicked. I use a stand alone version of IE 6(and it has some limits
> in functionality). I presume that somehow the id of the image is not
> passed to the new 'src' attribute. "this.get('id')" is taking the id
> of the image; I've putted an "alert" after the code line and the
> message shows correctly the image id.
> A day before the error thrown was of type :"Object expected", but
> today I can't see the error message anymore.
>
> Any help will be very appreciated.
>
> Thank you,
> Cristian Nistor

Reply via email to