Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<html>
<head>
    <script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
    <script>
        function resize() {
            var width = parseInt(d3.select("image").attr("width"));
            d3.select("image").attr("width", width / 2);
            var height = parseInt(d3.select("image").attr("height"));
                d3.select("image").attr("height", height / 2);
            displaySize();
        }
        
        function displaySize() {
            d3.select("#width").text(d3.select("image").attr("width"));
            d3.select("#height").text(d3.select("image").attr("height"));
        }
    </script>
</head>
<body>
    Image width: <span id="width"></span>
    <br>
    Image height: <span id="height"></span>
    <br>
    <button onclick="resize()">Resize image</button>
    
    <svg width="100%" height="100%">
        <image href="https://coubsecure-a.akamaihd.net/get/b46/p/coub/simple/cw_image/3a579636694/cfb4af2a89eefb4486c0e/cotd_email_1424699258_00013.jpg" 
        width="390" height="219" onload="displaySize()"/>
    </svg>
</body>
</html>
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers