How to hide the URL-bar in iOS safari

When writing an HTML5 game (or any other online application), it can be rather annoying sometimes that the URL-bar takes up a rather significant chunk of the screen. This script will remove the URL-bar. Please note that his only works for iPod and iPhone, not for iPads.

The code

The code is fairly simple. Just place the following code somewhere in your <head> tag:

<script type="application/x-javascript">
    addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false);

    function hideURLbar(){

The scripts scrolls to position (0,1), essentially positioning the page in the top-left corner, pushing the url-bar upwards.

The reason there is a Timeout of zero miliseconds is to make sure the page renders before the URL-bar is removed. More info here.

Leave a Reply

Name and website fields are completely optional.