Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
   <svg viewBox="0 0 200 200" style="height: 200px; width: 200px;" xmlns="http://www.w3.org/2000/svg">
    <rect width="100%" height="100%" fill="red"/>
    <rect id="rect" x="50" y="50" width="100" height="100" fill="green"/>
    <foreignObject x="50" y="50" width="100" height="100">
      <div style="background-color: yellow; width: 100px; height:100px;">
      </div>
    </foreignObject>
  </svg>
</body>
</html>
 
console.log(document.querySelector('foreignObject').getBBox());
console.log(document.querySelector('#rect').getBBox());
Output 300px

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

Dismiss x
public
Bin info
ayeressianpro
0viewers