How can I get width and height of SVG on Image.load in IE 11

后端 未结 3 1736
迷失自我
迷失自我 2021-01-03 21:43

It works fine everywhere but not in IE 11 (I have not tested other IE versions yet).

var img = new Image();
img.onload = function(){

   alert( \'img: \' + i         


        
3条回答
  •  情歌与酒
    2021-01-03 22:25

    In html5 standard:

    The IDL attributes width and height must return the rendered width and height of the image, in CSS pixels, if the image is being rendered, and is being rendered to a visual medium; or else the intrinsic width and height of the image, in CSS pixels, if the image is available but not being rendered to a visual medium; or else 0, if the image is not available. LINK

    If img not rendered then IE reserves the right to display 0. And it seems he is doing this.

    With .naturalWidth and .naturalHeight similar situation.

提交回复
热议问题