Height and width SVG

0

I have an SVG element and I want its height and width to fit according to the resolution. For this I'll get into javascript through the screen.width. Now I wanted to insert this value into the svg tag. Is it possible to do this?

<script>
 var window_width = screen.width;
 var window_height = screen.height;
</script>
<svg width="<script type='text/javascript'>screen.width</script>" height="500">

    
asked by anonymous 20.02.2015 / 17:29

1 answer

1

You can do so directly in the js, here below modify your code:

<svg id="xyz">

<script>
 var window_width = screen.width;
 var window_height = screen.height;

 var mySvg = document.getElementById("xyz");
 mySvg.style.width=window.width;
 mysvg.style.height=window_height;

</script>

Remembering that the script should come below the "svg" tag

    
20.02.2015 / 18:11