How do you disable viewport zooming on Mobile Safari?
Edit: may not work after iOS 10, please see touch-action
based solution below.
Your code is displaying attribute double quotes as fancy double quotes. If the fancy quotes are present in your actual source code I would guess that is the problem.
This works for me on Mobile Safari in iOS 4.2.
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
How to prevent zoom on chrome, firefox, safari?
Try this
$(window).bind('mousewheel DOMMouseScroll', function(event) {
if(event.ctrlKey == true)
{
event.preventDefault();
if(event.originalEvent.detail > 0) {
console.log('Down');
}else {
console.log('Up');
}
}
});
How to prevent native browser default pinch to zoom behavior?
I accidentally found a solution which works on Chrome. You basically have to preventDefault
the "wheel"
event. ctrlKey
will be true
if it is a pinch event instead of a scroll.
element.addEventListener('wheel', event => {
const { ctrlKey } = event
if (ctrlKey) {
event.preventDefault();
return
}
}, { passive: false })
I'd guess this is how Google Maps does it.
The (most) cross-browser solution is probably a combination of the techniques mentioned: user-scalable=no
in the "viewport"
meta tag for the browsers that do support it and this one for native Chrome.
Related Topics
Making Div Visible or Invisible Depend on Condition
How to Create a Simple Like Button
Navbar(Menu) Is Getting Overlapped by Body Element
Multiple Select Dropdown Not Working With Ng-Option
Why Is There a White Space Between Parent Div and Inner Div in React
Make a Div Fill the Height of the Remaining Screen Space
Best Way to Center a ≪Div≫ on a Page Vertically and Horizontally
How to Set the Default Value For an HTML ≪Select≫ Element
Stylesheet Not Loaded Because of Mime-Type
Chrome User Agent Stylesheet Overwriting My Site Style
Table With Fixed Header and Fixed Column on Pure CSS
Line Break in HTML Select Option
Rendering HTML Content With @Html.Raw in Razor Mail Template
100Vh Height When Address Bar Is Shown - Chrome Mobile
Maintain the Aspect Ratio of a Div With Css
Is It Valid to Replace Http:// With // in a ≪Script Src="Http://..."≫