问题
The following code doesn't work in IE 11 (Chrome works fine)
<html>
<head>
<script>
window.onload = function() {document.getElementById("abc").style.transform = "translate(100px,100px)";};
</script>
</head>
<body>
<div>
<svg width="200" height="200">
<g id="abc">
<polygon points="14,7 0,14 0,0"></polygon>
</g>
</svg>
</div>
</body>
回答1:
For IE you need to set transform as an attribute rather than as a CSS style.
Note that for an attribute, units are not allowed.
<html>
<head>
<script>
window.onload = function() {document.getElementById("abc").setAttribute("transform", "translate(100, 100)")};
</script>
</head>
<body>
<div>
<svg width="200" height="200">
<g id="abc">
<polygon points="14,7 0,14 0,0"></polygon>
</g>
</svg>
</div>
</body>
来源:https://stackoverflow.com/questions/37109349/svg-translate-transform-in-javascript-not-working-in-ie-11