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>
<input type="text" id="input">
</body>
</html>
 
var input = document.getElementById('input');
var focusChainoid = [];
window.addEventListener('focus', function (e) {
  if (e.target === window) {
    focusChainoid.push(e.target);
  }
}, false);
document.addEventListener('focus', function (e) {
  if (e.target === document) {
    focusChainoid.push(e.target);
  }
}, false);
input.addEventListener('focus', function (e) {
  if (e.target === input) {
    focusChainoid.push(e.target);
  }
  console.log(focusChainoid);
}, false);
input.focus();
// Firefox:       [document, window, <input>]
// Safari/Chrome:           [window, <input>]
// Edge/IE11:                       [<input>]
Output

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

Dismiss x
public
Bin info
cvrebertpro
0viewers