How do I get alerted in javascript that an image's dimensions are available? -


i need able wait start function until height , width of image available. when code calls start(), still says height , width zero:

var img = new image();  init = function() {     img.onload = this.start();     img.src = "sky.jpg";     }  start = function() {     alert("start called.\nwidth:"+img.width+"\nheight"+img.height);     }  init(); 

how can make wait until dimensions available before calling start()?

var img = new image();  var start = function() {     alert("start called.\nwidth:"+img.width+"\nheight"+img.height); }  var init = function() {     img.onload = start;     img.src = "sky.jpg"; }   init(); 

change this.start() start.

i scoped functions.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -