Tom Gullen
Tom Gullen

Reputation: 61773

iPhone Detect Zoom - Help!

This works in all my test browsers:

<body onresize="handleResize()">

 

// Aint perfect, but works well enough!
function handleResize()
{
    // Document.ready sets initialWidth = window.innerWidth;
    var zoomAmount = Math.round((initialWidth / window.innerWidth) * 100);
    $('#db').html(zoomAmount);
}

On iPhone when I use two fingers to zoom in and out, this number is not updated.

How can I trigger an event when the iPhone user zooms?

Upvotes: 1

Views: 590

Answers (1)

occulus
occulus

Reputation: 17012

You can't. When you pinch to zoom on the iPhone web kit, you're not actually resizing the view of the web page in the same sense as when you resize a browser window -- notice that the content doesn't reflow. All the iPhone is doing is blowing up a certain section of the complete web content.

Upvotes: 1

Related Questions