开发者

Resizing image size using javascript

I am trying to resize the image using javascript, but I am getting errors

 var y;
            var y = new Image();
            y.src = s;
            var wd = y.width/600;
            var ht =  y.height/600;


    if(ht>wd){
        var rw=round(wd * (1/ht));
        var hw1 = ht * (1/ht);
        var hw=round(hw1);
    } else {
        var rw1 = (wd) * (1/wd); 
        rw=round(rw1);
        hw=round(ht * (1/wd));
    }

I am getting errors saying

Message: Object expected Line: 27 Char: 2 Code: 0

Where line 27 is rw开发者_运维知识库=round(rw1);

Thanks Jean


The round method is not a global function, it's a method in the Math object.

Change every round in your code to Math.round.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜