How can I use JavaScript to set the zoom level on mobile safari?
Adjust the magnification: Double-tap the screen with three fingers (without lifting your fingers after the second tap), then drag up or down. Or triple-tap with three fingers, then drag the Zoom Level slider.
Open the Settings app , then scroll down and tap Safari. Scroll down and tap Page Zoom. Tap which percentage you would like the default zoom level to be for all websites.
[UPDATED] It seems that you want to capture double taps in mobile Safari. You could do that by handling the touchend
event, or use an available framework, such as provided in this site.
Take a look at the revised demo: http://jsbin.com/atayo4/20
<p id="tap">double tap to zoom</p>
<input id="zoomWidth" type="text" value="400" />
<p id="feedback"></p>
$(document).ready(function(){
$('#tap').doubletap(
// double tap handler
function(e) {
$('#feedback').addClass('red').html('double tap! Zoom width: ' + $('#zoomWidth').val());
var zoomWidth = $('#zoomWidth').val();
// zoom with the new width
$('meta[name="viewport"]').attr('content', 'width=' + zoomWidth + ', user-scalable:no');
$('#zoomWidth').val(parseInt(zoomWidth, 10) - 25);
},
// single tap handler
function(e) {
$('#feedback').removeClass('red').html('single tap! Zoom width: ' + $('#zoomWidth').val());
},
// double tap delay, default 500
400
);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With