Skip to content

Instantly share code, notes, and snippets.

@gregersrygg
Created July 18, 2011 22:13
Show Gist options
  • Save gregersrygg/1090825 to your computer and use it in GitHub Desktop.
Save gregersrygg/1090825 to your computer and use it in GitHub Desktop.
Scroll away addressbar for fullscreen webapps
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"/>
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<style>
article, aside, figure, footer, header, hgroup,
menu, nav, section { display: block; }
html, body { margin: 0px; height: 100%; }
body {
background-color: green;
border: 1px solid red;
}
</style>
<script>
addEventListener("load", function() {
var el = document.createElement("div");
el.style.width = "1px";
el.style.height = screen.height + "px";
el.style.visibility = "hidden";
document.body.appendChild(el);
setTimeout(function() {
window.scrollTo(0, 1);
document.body.style.height = window.innerHeight-2 + "px";
document.body.removeChild(el);
}, 100);
}, false);
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment