Create an iPhone Optimised Website using jQTouch

We have used the viewport meta key

We have used the viewport meta key to help improve the presentation of content displayed in Mobile Safari. Initial-scale is the scale that the content is viewed at when the user first visits the page and maximum-scale and minimum-scale are the scales that determine how much the user can zoom in/out on content. Because all of these values are 1 in our code the user is unable to zoom in/out on the content which is what we want. Or at least, what I want. There is also user-scalable which determines whether the user can zoom in and out on content. The default is yes and so because I don’t want my users to be able to zoom in, i’ve set it to no.

apple-mobile-web-app-capable sets whether the site can run in full-screen mode and apple-mobile-web-app-status-bar-style simply sets the style of a status bar for a Mobile Safari web app.

The HTML Structure continued…

Now that the basic device/content rules are set up we can get on with developing the optimised website. It’s time to link to our CSS and Javascript Files. Reference to the jQTouch stylesheet (full or min) and also link to your main stylesheet that will contain the sites styles.

<link rel="stylesheet" href="assets/jqtouch/jqtouch.css" type="text/css" media="screen" /></div>
<link rel="stylesheet" href="assets/css/main.css" type="text/css" media="screen" /></div>

Now we want to add references to the needed Javascript Files. From the jQTouch you want to link to jquery1.3.2.min.js and jqtouch.js. In your own javascript directory you want to create a file called global.js. In the end these are the links we’ll have.

<script type="text/javascript" src="assets/jqtouch/jquery.1.3.2.min.js"></script></div>
<script type="text/javascript" src="assets/jqtouch/jqtouch.js"></script>
<script type="text/javascript" src="assets/js/global.js"></script>

That’s the header section complete, for now.

Pages: 1 2 3 4 5

This entry was posted on Monday, June 7th, 2010 at 09:00 and is filed under Tutorials. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Matthew Leak is a freelance Web Designer and Developer from Manchester in the UK with an avid interest for new and exciting web technologies and trends. Follow Matthew’s updates on Twitter and be sure to check out his blog.

About the author Published by Matthew Leak

19 Responses »

  1. Isn’t it awesome? 🙂

  2. Can’t see the demo… blank site!
    Google Chrome, by the way.

  3. The demo is working for me? Are you trying to view the demo with Javascript disabled?

  4. I really like and appreciate your blog.Really thank you! Awesome.

  5. The sliding did not work for me after following the tutorial. After troubleshooting, I found that the global.js is missing this part which is responsible for the sliding from one page to another:

    $(function(){
    jQT.addAnimation({
    name: ‘slide’,
    selector: ‘.revealme’
    });
    });

    In the end the content of my global.js file looks like this:

    var jQT = new $.jQTouch({
    icon: ‘jqtouch.png’,
    addGlossToIcon: true,
    startupScreen: ‘jqt_startup.png’,
    statusBar: ‘black’,
    preloadImages: []
    });

    $(function(){
    jQT.addAnimation({
    name: ‘slide’,
    selector: ‘.revealme’
    });
    });

    And then the app started working like your demo.

    Thanks for this tutorial!

  6. Nice Tutorial! I’m also playing around with jqTouch actually
    but reached very fast my boundaries of comprehension about
    jQuery + jqTouch.

    For example, use custom events or trigger something if first li is entered. Or why the hell already tested functions dont work anymore
    or with interrupts.
    I think i need more table edges for my head here.

    If you are interest, you can have a look about it here:
    http://stackoverflow.com/questions/3548853/jqtouch-event-handling-and-strange-behaviour-of-functions

    Best regards,
    Thomas

  7. Making a website is really not that tough, and top of all, you can create a website or more website for free.
    Building a website is a extremely individual skill and is different with each client.
    It is more about revealing your business to new probable clients and generating new sales.

  8. Hi,

    Thanks for the tutorial. Just a little observation about the viewport metas. These seem to be useless unless you set the fixedViewport option to false when initializing jQTouch.

    Indeed, this option is set to true by default so jQTouch defines its own values for the viewport.

    On the example above, the values set in the metas are the same than the jQTouch ones, so no everything’s displayed as expected. But if you wanna change the scales, for example, you have to set the fixedViewport to false.

  9. These lines:

    are actually not required if you set the fullScreen and statusBar options to true, so jQTouch will take care of it.

    I know these are details, but I think it’s cleaner to let jQTouch do the job 😉

    Anyway, this library definitely needs a documentation… >_<'

  10. Argh, the lines of code were filtered. I was talking about the “apple-mobile-web-app-capable” and “apple-mobile-web-app-status-bar-style” metas.

  11. does this work on android phones?
    (i don;t have an android to check)

    • Amazing, you have explained all the fundamentals of jqtouch for websites, including a detailed explaination of the viewport (which before didn’t really know much about), and plus it works almost seamlessly on Android! Thanks Matt!

  12. Hi,
    Thanks for Wonderful tutorial.
    I have one question.
    Your all page was static, if i want to dynamic pages from asp.net than how it will work?

    Thanks
    Ashish

  13. Hey is there any reason why this doesnt work on a blackberry phone? I know this is ment for iPhone but what if i wanted to use this for blackberry too. Any suggestions on how to get this to work?

  14. Hello
    I had tried everything but the menu can not be clicked.Links works sometimes only the first two and so there is no more..I’ve tried thet tip from Hari butdid not helpt..

Trackbacks

  1. designfloat.com