tags:

views:

18

answers:

2
+1  A: 

.load() is a jQuery function so you need a wrapper, and bind it before setting the src, like this:

$("#someID").click(function(event){
  event.preventDefault();
  var newImage = new Image();
  $(newImage).load(function(){
    alert(this.width);
  });
  newImage.src = this.href;
});
Nick Craver
Works fine, thanks!
Maurice
A: 

Your second example is close; you need to wait for the image to load first, before you can retrieve the dimensions of it.

$('#someId').bind('click', function (event) {
  var image = new Image();
  image.onload = function () {
    var height = this.height;
    var width = this.width;

    alert(height + " | " + width);
  }
  image.src = this.href;

  event.preventDefault();
});

You can see a working fiddle here: http://www.jsfiddle.net/JsRmU/

Matt
Thanks for helping!
Maurice