0

我以编程方式在 Web 服务器上生成蒙版图像,然后使用以下代码将其应用于 HTML 元素:

imageToMask.style["-webkit-mask-box-image"] = "url('" + featherURL +"') 100 stretch";

我怎样才能知道图像何时返回并完成下载,以便它不只是弹出到页面上?

4

1 回答 1

1

You can probably do something similar to what @lonesomeday did in:

jQuery .on() not bound when script inserted into the DOM

Something along these lines:

 $('button').click(function() {
     var imageToMask = document.createElement('img');
     imageToMask.style["-webkit-mask-box-image"] = "url('" + featherURL +"') 100 stretch";

     imageToMask.onload = function() {
        //Custom behaviour
     };
     document.body.appendChild(imageToMask);
 });
于 2012-07-11T01:17:53.957 回答