Skip to content

Instantly share code, notes, and snippets.

@talnetd
Created June 21, 2013 10:03
Show Gist options
  • Save talnetd/5830220 to your computer and use it in GitHub Desktop.
Save talnetd/5830220 to your computer and use it in GitHub Desktop.
Inspired from David and tweak myself for a better internal understanding.
<!doctype html>
<html>
<head>
<title>Html5 Context Menu</title>
<style type="text/css">
body {
padding:0;
margin:0;
}
.container {
width:50%;
height: auto;
margin: auto;
padding-top: 10%;
}
#header {
width:100%;
text-align: center;
padding-top:45px;
padding-bottom: 50px;
background:#ddd;
border:solid 5px #000;
}
#header header h1 {
font-size: 5em;
color: #fff;
text-shadow: 3px 3px 3px #000;
font-family: Arial;
}
</style>
</head>
<body>
<div class="container">
<section id="header" contextmenu="mymenu">
<header>
<h1>HTML5</h1>
<menu type="context" id="mymenu">
<menuitem label="Refresh Post" onclick="window.location.reload();" >
</menuitem>
<menu label="Share on...">
<menuitem label="Twitter" onclick="goShare('http://twitter.com/intent/tweet?text=' + document.title + ': ' + window.location.href);">
</menuitem>
<menuitem label="Facebook" onclick="goShare('http://facebook.com/sharer/sharer.php?u=' + window.location.href);">
</menuitem>
</menu>
</menu>
</header>
</section>
</div>
</body>
<script>
function goShare(url) {
window.open(url, "shareWindow");
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment