Drawing an svg containing html in a canvas with safari

后端 未结 2 1580
耶瑟儿~
耶瑟儿~ 2021-02-20 11:02

I\'m trying to create some thumbnails of dynamically created pages for a website, i have found a solution by adding the html in a svg which I then draw on an image inside a canv

2条回答
  •  醉梦人生
    2021-02-20 11:27

    You don't state what you get in console on the Blob nor the URL.

    Just a shot but you are revoking the url right after setting it as source on the image. You need to revoke if after the image has been loaded in the onload event:

    img.onload = function() {                   
        DOMURL.revokeObjectURL(url);      /// here
        context.drawImage(img, 100, 100);                                       
    };
    
    img.src = url;
    //DOMURL.revokeObjectURL(url);        /// not here
    

    See that helps out. If not then you're probably dealing with a Safari specific issue. (your canvas specific translate etc. should also be inside the onload event or at least called before you set the src property).

提交回复
热议问题