aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes image prototype onload Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "image prototype onload" Watch "image prototype onload" New topic
Author

image prototype onload

Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
I'm screwin' around to deepen my understanding of javascript OOP and event handling sorts of things. Recently, I've been beating image loading to death. No particular reason behind the specific way I want to do things, other than to learn about it.

I've been creating image objects in a loop and setting the onload attribute on each instance. It occurred to me that I should be able to set it for the Image object instead:


but I couldn't. "'Image.prototype' is null or not an object" At this point I am assuming that onload event handler cannot be added directly to the Image() object.

I started wondering then whether I could create an object based on Image() that would allow it's onload property to be set; something like:


I've thought about creating a whole new object with this.oImg = new Image() and an onload property in it, but ... that's for another exercise. This time around, I just want to know if it's possible to do something like what's described above.
[ April 22, 2007: Message edited by: Roger F. Gay ]

Correlation does not prove causality.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61221
    
  66

Apparently the Image class is a wrapper around a native object rather than a pure Javascript object like String. As such, the ability to manipulate it is signficantly curtailed.

This makes it a poor choice for a study on OOP in Javascript.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
Thanks Bear. I think I'll leave it alone, based on your comment. I can't help but think in practical terms anyway sometimes, even when I'm trying to go off on strange tangents for the learning experience -- and it has been getting a little difficult to feel that this is an interesing problem, given the minor impact (if any) that it would have on the actual functioning of what I've built.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
Originally posted by Bear Bibeault:
Apparently the Image class is a wrapper around a native object rather than a pure Javascript object like String. As such, the ability to manipulate it is signficantly curtailed.

This makes it a poor choice for a study on OOP in Javascript.


And BTW, I did learn something along the way. Thanks again.
Roger F. Gay
Ranch Hand

Joined: Feb 16, 2007
Posts: 376
A solution was given that works in some browsers:

http://www.tek-tips.com/viewthread.cfm?qid=1359301
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: image prototype onload