Skip to content

Instantly share code, notes, and snippets.

@billibala
Created July 30, 2013 02:08
Show Gist options
  • Save billibala/6109619 to your computer and use it in GitHub Desktop.
Save billibala/6109619 to your computer and use it in GitHub Desktop.
Fake a Mac OS X focus ring for DOM element in a web view
<html>
<head>
<title>Focus ring</title>
<meta name="author" content="Headnix">
<style type="text/css" media="screen">
.thumbnail {
width: 100px;
height: 100px;
background-color: #eee;
}
.highlighted {
outline: 2px auto -webkit-focus-ring-color;
}
</style>
</head>
<body>
<div class="thumbnail" onclick="highlightItem(this)">
</div>
<script>
function highlightItem(anElem) {
if ( anElem.classList.length > 1 ) {
anElem.classList.remove("highlighted");
} else {
anElem.classList.add("highlighted");
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment