0

我有一个浏览区域,用户可以在其中浏览并输入图像。

我需要知道图像的高度和宽度来限制它。

var img= IWDatacapture.getItem("banners/mobile-banner/mobile-content[1]/main-image");
var params = new Object();

if(img.length==undefined)
{
    var savnm = IWDatacapture.getWorkarea() + img.getValue();
    params.savnm = savnm;               
    var server = window.location.hostname;
    IWDatacapture.callServer("http://"+server+"/iw-bin/iw_cgi_wrapper.cgi/getFileSize.ipl", params,true);
}

进行服务器调用后,我不明白如何访问图像的属性。

4

1 回答 1

0

尝试类似:

// Get the full image URL:

var img = IWDatacapture.getItem("banners/mobile-banner/mobile-content[1]/main-image");

// Note: I'm not sure if the following will generate the correct URL, but it should be close. Double check the "workarea" part.

var fullImagePath = "/iw/cci/meta/no-injection/iw-mount/" + IWDatacapture.getWorkarea() + img.getValue();

// Then load the image in the browser to get the dimensions:

var image = new Image();

image.onload = function(){
  var height = image.height;
  var width = image.width;

  // Whatever you want to do

}

image.src = fullImagePath;
于 2016-01-18T01:19:08.450 回答