Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="box" class="box"></div>
  
  <div id="result" class="rs"></div>
</body>
</html>
 
var box = document.getElementById('box'),
    x, y, w;
x = box.getBoundingClientRect().left;
y = box.getBoundingClientRect().top;
if (box.getBoundingClientRect().width) {
  w = box.getBoundingClientRect().width; // for modern browsers
} else {
  w = box.offsetWidth; // for oldIE
}
document.getElementById('result').innerHTML = '<strong>This box is</strong>:<br>' + x + 'px from the left<br>' + y + 'px from the top<br>' + w + 'px wide<br>';
Output

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

Dismiss x
public
Bin info
ImpressiveWebspro
0viewers