Skip to content

Instantly share code, notes, and snippets.

@javan
Created February 7, 2016 00:41
Show Gist options
  • Save javan/be0bfcfe237f7583d2e4 to your computer and use it in GitHub Desktop.
Save javan/be0bfcfe237f7583d2e4 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<style>
body {
padding: 60px;
}
.highlight {
background-color: yellow;
}
webview {
display: inline-block;
width: 200px;
height: 60px;
}
</style>
<script>
addEventListener("mousedown", function(event) {
if (event.target === document.body) {
document.body.classList.add("highlight")
}
})
addEventListener("mouseup", function(event) {
if (event.target === document.body) {
document.body.classList.remove("highlight")
}
})
</script>
</head>
<body>
<webview src="./webview.html"></webview>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-color: red;
}
.highlight {
background-color: yellow;
}
</style>
<script>
addEventListener("mousedown", function(event) {
if (event.target === document.body) {
document.body.classList.add("highlight")
}
})
addEventListener("mouseup", function(event) {
if (event.target === document.body) {
document.body.classList.remove("highlight")
}
})
</script>
</head>
<body>
<input type="text">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment