This is because your newImg is not an extended element.
Create a new img element using:
new Element('img');
or use the prototype dollar function (http://api.prototypejs.org/dom/dollar/)
to properly extend your element with the prototype methods:
$(newImg);
Your addImage method could be rewritten like this:
function addImage(src, div) {
var newImg = new Element('img', { id: "Image" + div, src: src
}).observe('load', loadcrop);
$("img" + div).show().insert(newImg);
$("upload" + div).hide();
}
For more information about how prototype extends the DOM:
http://prototypejs.org/learn/extensions
And the other Element functions i've used:
http://api.prototypejs.org/dom/Element/
Greetings,
Johan
On Tue, Jun 28, 2011 at 5:06 PM, edwingt <[email protected]> wrote:
> Hello I'm trying to do an event observe work on IE, it works good on
> FF and Chrome, this is the script. When the newImg.observe() is
> reached I catch an exception with this msg "'src' is undefined"
>
> function addImage(src, div) {
> var newImg = document.createElement("img");
> newImg.id="Image"+div;
>
> document.getElementById("img"+div).appendChild(newImg);
> papa=document.getElementById("img-upload");
> document.getElementById("img"+div).style.display="block";
> hijo=document.getElementById("upload"+div).style.display="none";
>
> newImg.src = src;
> newImg.observe('load', loadcrop);
> }
>
> function loadcrop(evt)
> {
>
> img = evt.findElement();
> var txt = new String(img.id);
> addCrop(txt.slice(5,6));
> }
>
> Thanks if you can help me solve this problem.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" group.
> To post to this group, send email to
> [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/prototype-scriptaculous?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/prototype-scriptaculous?hl=en.