Menu Close

WebApps with multiple pages

 

In iOS is useful add a site to home screen for have a webapp of your site without address bar and others (for how to do it, see HERE).

The issue is that if the page have links to other pages for open them iOS uses safari instead of stay in Full Screen Mode.

For avoid this, you can use a simple trick adding this script at the top of every page that have external link:

 

  <script type="text/javascript">  
  $(window).click(handleClick);

  function handleClick(e) {
    var target = $(e.target).closest('a');
    if( target ) {
        e.preventDefault();
        if (target.attr('href') != undefined)
        {
          window.location = target.attr('href');
        }
    }
  }
  </script>

 

With this script, you don’t have to modify every single href attribute of the page, and you can decide to enable it only if the agent of client is iOS.

Posted in Mobile Development, News, Web Development

Leave a Reply

Your email address will not be published. Required fields are marked *