Stretch <svg> inside an <embed> to fit window size
问题 I am trying to stretch an svg document inside an DOM in order to fit the window size. like so: <div id="y"> <div id="button"> click to zoom</div> <embed id="x" src="s17.svg" > <script> var btn= document.getElementById("button"); btn.addEventListener('click',function(){ var z= document.getElementsByTagName("embed")[0]; var y = z.getSVGDocument(); y.lastChild.setAttribute("viewBox","0 0 "+window.innerWidth+" "+window.innerHeight); },false); </script> </div> css: #x{ height:100%; width:100%;