Skip to content

Instantly share code, notes, and snippets.

@jzazove
Created November 29, 2012 14:13
Show Gist options
  • Save jzazove/4169358 to your computer and use it in GitHub Desktop.
Save jzazove/4169358 to your computer and use it in GitHub Desktop.
Removing Safari URL Address Bar from Mobile when Orientation Changes Occur
(function() {
function s() {
var e = document.createElement("div");
e.style.height = "10001px";
document.body.appendChild(e);
setTimeout(function() {
window.scrollTo(0, 0);
document.body.removeChild(e);
}, 1);
};
function a() {
var n = navigator.userAgent;
return (
n.match(/iPhone/i) || n.match(/iPad/i))
};
s();
if (a()) {
window.addEventListener('orientationchange', function(evt) {
s();
}, false);
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment