Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had problems with the iPhone viewport and JQuery-Mobile as well, I ended up with the following solution.</p> <ul> <li>Add a meta tag that sets the height and width to the device-height/device-width (you can allow the user to zoom by changing the maximum-scale to something above 1 however zoom is disabled in the following example, I believe Mobile Safari allows a value up to 10):</li> </ul> <p><code>&lt;meta name="viewport" content="height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0" &gt;</code></p> <ul> <li>As the user changes the orientation on iPhone I noticed some strange behaviors with re-scaling and added white-space so I used the following code:</li> </ul> <pre> //check the navigator.userAgent string to detect if the user is using an iPhone if (navigator.userAgent.match(/iPhone/i)) { //cache the viewport tag if the user is using an iPhone var $viewport = $('head').children('meta[name="viewport"]'); //bind an event handler to the window object for the orientationchange event $(window).bind('orientationchange', function() { if (window.orientation == 90 || window.orientation == -90 || window.orientation == 270) { //landscape $viewport.attr('content', 'height=device-width,width=device-height,initial-scale=1.0,maximum-scale=1.0'); } else { //portrait $viewport.attr('content', 'height=device-height,width=device-width,initial-scale=1.0,maximum-scale=1.0'); } //trigger an orientationchange event on the window object to initialize this code (basically in-case the user opens the page in landscape mode) }).trigger('orientationchange'); } </pre> <p>The if/then statement in the event handler checks for which orientation the user has changed to (90, -90, and 270 are all values I've seen for landscape) and the <code>$viewport.attr('content',...</code> lines just switch the height and width values in the viewport tag.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload