View Single Post
Old 11-12-2012, 03:00 PM   PM User | #2
devnull69
Senior Coder

 
Join Date: Dec 2010
Posts: 2,245
Thanks: 10
Thanked 531 Times in 525 Posts
devnull69 will become famous soon enough
It would work ... but the image must be attached to the DOM otherwise it will (of course) not be visible and not be clickable.
Code:
object.prototype.clickme = function() {
   alert('Hooray!');
};

object.prototype.setImage = function(src) {
   this.picture = new Image();
   this.picture.src = src;
   document.body.appendChild(this.picture);
   this.picture.addEventListener('click' , this.clickme, false);
};
devnull69 is offline   Reply With Quote
Users who have thanked devnull69 for this post:
Ben Stuijts (11-12-2012)