Thursday, August 8, 2013

keep an HTML5 page from scrolling on an iPhone

I'm not really confident in window.scrollTo(0, 1); but the rest of this is golden.

<script language="javascript">
   window.scrollTo(0, 1);
   $(function () {
      setInterval("resizeMobileScreen();", 500);
   });
   function resizeMobileScreen() {
      windowWidth = document.all ? document.body.clientWidth : window.innerWidth;
      windowHeight = document.all ? document.body.clientHeight : window.innerHeight;
      document.getElementById("viewport").setAttribute('content', 'width=device-width,
            width=480, maximum-scale=1.0, minimum-scale=1.0');
   }
</script>

No comments:

Post a Comment