• Home
  • New Entries
  • Popular Entries
  • Submit a Story
  • About

iPhone Optimization Script ...

I bought an iPhone about six months ago; in that time I noticed that even though it had this part of the Web and that part of the Web. Every page I went to I was only reading this part and in order to do that, I needed to scroll it into view and resize the page the same way every time.

View More Info



Bob Buffone has created a tool that can be used to output script and HTML to make your site more usable on an iPhone. He tells us about it here:

    I bought an iPhone about six months ago; in that time I noticed that even though it had this part of the Web and that part of the Web. Every page I went to I was only reading this part and in order to do that, I needed to scroll it into view and resize the page the same way every time. When I go Ajaxian.com on my iPhone I need to scroll the content to the right location and scale it so the middle column fits the screen and then start reading. It’s a real pain in the ass.

    This was the case for my blog as well. I didn’t want to rewrite it so I figured out a way to use a little JavaScript to set the scale and position of the page at start up so the main content area completely fills the screen for the iPhone.

Once you input the URL to your site, it gets loaded and you can interact with it to put the box in the right place. For Ajaxian, it then output the following HTML:

PLAIN TEXT
HTML:


   1.
      
   2.
      <meta name="viewport" content="width=980; initial-scale=0.631163708086785"/>
   3.
      

and JavaScript to do the right thing on the iPhone:
PLAIN TEXT
JAVASCRIPT:


   1.
      
   2.
      (function(){
   3.
            
   4.
              //Variable used to control the zoom and
   5.
              //position of the page when it is loaded.
   6.
              var viewport = {
   7.
                      initialScale: 0.631163708086785,
   8.
                      width: 980
   9.
              };
  10.
              //(-80) is for the navigation bar, otherwise you can read it
  11.
              //until it is fully loaded
  12.
              var scrollPosition = {
  13.
                      left: 198,
  14.
                      top: (188-80)
  15.
              };    
  16.
              if (/iPhone/i.test(navigator.userAgent)) { // sniff    
  17.
                      //write the meta tag for the initial scale.  This should
  18.
                      //happen in the <head> section of the html page.
  19.
                      document.write(<meta name="viewport" content="width=+
  20.
                                              viewport.width+; initial-scale= +
  21.
                                              viewport.initialScale + ">);
  22.
            
  23.
                      //This loop will catch the page is loaded with out needing
  24.
                      //to use the onLoad event.
  25.
                      var _timer = setInterval(function(){
  26.
                      if (/loaded|complete|interactive/.test(document.readyState)) {
  27.
                              clearInterval(_timer);
  28.
                                                                     
  29.
                              //This will scroll the content into view,
  30.
                              //could be enhanced with animated scrolling but less is more.
  31.
                              //if the user started scrolling then let them handle it.
  32.
                              if (window.pageXOffset == 0 && window.pageYOffset == 0)
  33.
                                      window.scrollTo(scrollPosition.left,
  34.
                                      scrollPosition.top);
  35.
                      }}, 10);
  36.
          }
  37.
      })();
  38.

source: ajaxian

 View Full Story.
Posted at 07:51:54 am | Permalink | Posted in Javascript  

Related Stuff

  • MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.

  • Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone

  • TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support

  • ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.

  • Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.

  • Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software

  • PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.

Be the first ... |Add your comment.

Your Comment ...

  Name (required)

  Email (required, hidden)

  Website


About Ajaxlines

Ajaxlines is a project focused on providing its audience with a database of most of Ajax related articles, resources, tutorials and services from around the world.

Its purpose is to showcase the power of Ajax and to act as a portal to the Ajax development community.


Recent Stuff

Growl for Windows and a Web Notification API

Learn AJAX from Scratch - Part II

Learn AJAX from Scratch - Part I

PHP AJAX CHAT, Bug fixes - including weird mozilla bug

Learn PHP From Scratch

40+ Tooltips Scripts With AJAX, JavaScript & CSS


Our Partners

Ajax Projects

Web 2.0 Sites

Webloglines

Human Development Handbook

Software Development Company

Ajaxlines


Search


Topics

  • .Net (95)
  • Articles (76)
  • Bookmarking (35)
  • Calendar (18)
  • Chat (38)
  • ColdFusion (3)
  • CSS (30)
  • Email (23)
  • Flash (13)
  • Games (6)
  • Google (17)
  • Html (6)
  • Image (11)
  • International Calls & VOIP (7)
  • Java (34)
  • Javascript (146)
  • JSON (15)
  • Perl (2)
  • PHP (82)
  • Presentation (19)
  • Python (3)
  • Resources (1)
  • RSS (1)
  • Ruby (7)
  • Storage (4)
  • Toolkits (87)
  • Tutorials (190)
  • UI (11)
  • Utilities (161)
  • Web2.0 (13)
  • XmlHttpRequest (18)
  • YUI (4)

© 2006 www.ajaxlines.com. All Rights Reserved. Powered by IRange