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>
  <img src="http://some.com/broken/url" />
  <div></div>
</body>
</html>
 
html,
body {
  font: bold 64px/1em helvetica, sans-serif;
  background: #FFF;
  word-break: break-word;
}
 
var image = document.querySelector('img');
var div = document.querySelector('div');
image.addEventListener('error', function(event) {
  var target = event.target;
  target.style.display = 'none';
  div.innerHTML = 'An image failed to load and has been hidden.';
});
Output

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

Dismiss x
public
Bin info
wilsonpagepro
0viewers