iPhone Detect Zoom - Help!

2019-08-07 11:48发布

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?

1条回答
▲ chillily
2楼-- · 2019-08-07 12:12

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.

查看更多
登录 后发表回答