Optimizing Your Site for the Iphone
Oct 23rd, 2009 | By Dee | Category: Featured Articles, Html and Design, Techie TimeIn the early days of the iPhone there were no webmaster guidelines whatsoever. Nowadays, they have specific web development guidelines for you to follow. In order to access it you first have to register as an iPhone developer at http://developer.apple.com/iphone. This includes a nice little simulator of an iPhone so that you can easily see how your apps are working.
One of the most obvious differences between the iPhone and your PC/Mac is the size of the screen. The iPhone maxes at 480dpi in landscape view. If your page already works on your desktop web browser you can easily create a custom css to be called when it is being viewed on an iPhone. The markup you would use is as follows:
<!–[if !IE]>–>
<link
rel=”stylesheet”
href=”small-screen.css”
type=”text/css”
media=”only screen and (max-device-width: 480px)”
/>
<!–<![endif]–>
Another feature you should strongly consider when designing for an iPhone is the two orientation modes: portrait and landscape. By using some simple JavaScript you can teach your program to react to changes in the orientation. The property you will be accessing is window.orientation. It has these values:
~ 0—normal portrait orientation (home button is at the bottom)
~ -90—landscape after clockwise rotation from portrait (home button to the left)
~ 90—landscape after counterclockwise rotation from portrait (home button to the right)
~ 180—unsupported for now, but would be portrait-flipped so that the home button is at the top
Also, you can program your app to initiate an orientation change event when the iPhone is tilted one way or another. This is accomplished by calling the window.orientation value with JavaScript. Following is an example of a script that will send an alert anytime the orientation changes:
window.onorientationchange = function() {
alert(window.orientation);
}
If you have been surfing on an iPhone you may have noticed how the URL toolbar is visible when you first visit a webpage but disappears as you start to scroll down. This is accomplished by using the window.scrollTo property to scroll down one pixel. Here is the code:
window.addEventListener(‘load’, function(){
setTimeout(scrollTo, 0, 0, 1);
}, false);
In the case that your page is not long enough to be scrollable you will need to add an additional meta element. Use this code:
<meta name=”viewport” content=”height=device-height,width=device-width” />
One of the properties that makes the iPhone so beautiful is the rounded corners. It is easier than you might expect to give your web app the same properies. It is simple css. Use this code:
.box {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
background: #ddd;
border: 1px solid #aaa;
}
You should be able to do whatever you want with the iPhone developers toolkit I mentioned in the first part of the article. I hope that I have illustrated just how easy it can be to make your web app work on an iPhone, though.
We Recommend:
The Native Remedies Affiliate Program
The Native Remedies Affiliate Network is a Two-tier program with high conversion rates and top level commissions. You can Earn 25% commissions on each direct sale and 5% on second tier sales – so even affiliates that sign up via your site earn you commissions!
Commissions are lifetime! – so each time your customer buys again, you get commissions! Click now to learn more about the NativeRemedies/PetAlive Affiliate Program!
Become a Wholesale, Dropship or Distributor Customer!
As demand for NativeRemedies and Pet Alive natural health products & remedies have grown, so has the opportunity for distributors, wholesalers and drop shippers to partner with us. Whether you are a small or large retailer, alternative health provider, an individual with a broad network of associates or a large distributor, Native Remedies has a reseller program designed just for you!
Wholesale Purchase Program – For individual resellers, retail stores, health providers or others who purchase in bulk and who resell the products directly to consumers.
Drop Ship Purchase Program – For those who do not wish to order in bulk but who wish resell our products along with others and then have us drop ship the products for them. (No Dropship Fees!)
Distributor Purchase Program – For large distributors who typically wholesale our products to retail stores and health practitioners and who can meet the higher minimum order volumes.
MaxBlogPress Ninja Affiliate System
It’s no secret that 95% of all bloggers out there make pennies from affiliate marketing, while a select few who are privileged enough to be in the “inner circle” make thousands of dollars effortlessly. Ninja Affiliate is WordPress plugin developed to imbue lethal marketing powers into your WordPress blog and instantly double or triple your affiliate marketing commissions with almost no effort on your part.
Using Ninja Affiliate, you can automatically convert any keyword in your blog to an affiliate link instantly. You can also cloak your affiliate links, track them and manage them right from your WordPress text editor. AffiliateRugu uses and highly recommends Ninja Affiliate by MaxBlogPress!

.jpg)
