[removed] How can I delay returning a value for img.complete

前端 未结 1 1626
甜味超标
甜味超标 2021-01-03 05:01

I\'ve written a script to test for SVG support in the IMG tag:

function SVGinIMG() {
  var SVGdata = \'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3         


        
相关标签:
1条回答
  • 2021-01-03 06:04

    I was complicating things a little; all I really needed was the load event:

    function SVGDetect() {
      var testImg = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNzUiIGhlaWdodD0iMjc1Ij48L3N2Zz4%3D';
      var img = document.createElement('img')
      img.setAttribute('src',testImg);
      img.addEventListener('load',setCSS,true);
    }
    

    This runs another function when the image loads, which is never in the case of browsers that don't support SVG in images.

    0 讨论(0)
提交回复
热议问题