Obtaining an original SVG viewBox via javascript

后端 未结 4 1769
南笙
南笙 2021-01-07 17:53

Our system loads SVG files programmatically into HTML via AJAX. A typical SVG file begins with:

 

        
4条回答
  •  北荒
    北荒 (楼主)
    2021-01-07 18:49

    Above receipes gave me all zeros for the x, y, width and height viewBox attributes -- unless at least one of them was changed programmatically.

    I finally succeded with

    var width = document.getElementById("mysvg").getAttribute("width");
    

提交回复
热议问题