Skip to content

Instantly share code, notes, and snippets.

@EvanHahn
Last active December 10, 2015 21:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EvanHahn/4498026 to your computer and use it in GitHub Desktop.
Save EvanHahn/4498026 to your computer and use it in GitHub Desktop.
Example page that does its best to disable copy-paste. For more: <http://evanhahn.com/?p=379>
<!DOCTYPE html>
<html>
<head>
<style type="text/css">
body {
-webkit-user-select: none;
-khtml-user-drag: none;
-khtml-user-select: none;
-moz-user-select: none;
-o-user-select: none;
-ms-user-select: none;
user-select: none;
}
::selection {
background: transparent;
}
</style>
<script type="text/javascript">
document.ondragstart = function() { return false };
document.onselectstart = function() { return false };
</script>
</head>
<body unselectable="on">
<h1 unselectable="on">You can't select this!</h1>
<p unselectable="on">You can't select this either. <a href="http://evanhahn.com/" unselectable="on">You can't even select <i unselectable="on">this!</i></a></p>
</body>
</html>
<!-- Code licensed under the Unlicense. -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment