Skip to content

Instantly share code, notes, and snippets.

@dfreedm
Created July 18, 2012 00:30
Show Gist options
  • Select an option

  • Save dfreedm/3133189 to your computer and use it in GitHub Desktop.

Select an option

Save dfreedm/3133189 to your computer and use it in GitHub Desktop.
Element From Point test
<!DOCTYPE html>
<html>
<head>
<!--<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0">-->
<title>ElementFromPoint test</title>
<style>
/* make rows an easy, visible height */
div {
height: 50px;
width: 100%;
}
/* show the even ones */
div:nth-child(even) {
background-color: blue;
}
/* remove any sources of confusing offsets */
html, body, div {
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<script>
/* create a good amount of rows */
for (var i = 0; i < 15; i++) {
var d = document.createElement("div");
d.id = i;
document.body.appendChild(d);
}
if (document.elementFromPoint) {
/* 100x37 should be in the first row always right? */
var message = "ElementFromPoint 100x37. This element should be id 0: id " + document.elementFromPoint(100, 37).id;
console.log(message);
alert(message);
} else {
console.warn("No document.elementFromPoint. Use webkit browser please");
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment