Skip to content

Instantly share code, notes, and snippets.

@bclinkinbeard
Created October 12, 2016 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bclinkinbeard/066f94e1469120d91e1b6e0441da58c1 to your computer and use it in GitHub Desktop.
Save bclinkinbeard/066f94e1469120d91e1b6e0441da58c1 to your computer and use it in GitHub Desktop.
D3 listener collisions across iframes
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
circle {
fill: green;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.3/d3.min.js"></script>
</head>
<body>
<svg width="300px" height="300px">
<circle cx="10" cy="10" r="10"></circle>
<circle cx="10" cy="35" r="10"></circle>
<circle cx="10" cy="60" r="10"></circle>
</svg>
<script>
d3.selectAll('circle')
.on('click', function () {
d3.select(this).style('fill', 'red');
})
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<iframe src="frame.html" frameborder="0"></iframe>
<iframe src="frame.html" frameborder="0"></iframe>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment