3

I need to disable the ability of the mobile browsers to zoom in/out for one of the tabs of my main menu. I am running Joomla 2.5. I tried installing the Simple Mobile Detection extension , however this ruined all my tabs URLs. So is there any way to set the meta viewport tag in Joomla ?

Thank You.

2

You can do this using Joomla built in setMetaData function, like so:

$doc = JFactory::getDocument();
$doc->setMetaData('viewport', 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no');

This will set the scale to 100% (default) and disable the ability to zoom in

  • girlintech - You're welcome. However please bare in mind, as @Seth has mentioned in his answer, even though it's possible, a very bad idea to do this. – Lodder Jul 2 '15 at 12:47
4

As @lodder answered you can set this meta to prevent zooming, and that is the correct way to do it, but you shouldn't do this.

Disabling native browser accessibility functions is a really bad idea, a clear ‘F%$K YOU!’ to your users. No-one needs to disable browser zoom.

Why not disable mouse clicks as well? Exactly. It's not very friendly to deliberately hobble a users device is it? If your design breaks when a user zooms, you should fix your design, not cripple standard user interactions.

Here's what the Accessibility Project has to say about this (mis)usage of the viewport meta: Never use maximum scale=1.

This quote, from an article by Brad Frost, puts a more human, and more direct, face on it I think:

Next time you find yourself intentionally depriving someone an experience—to acquire knowledge, to complete a task, to do something online that can make their life even just a little better—picture yourself standing in front of that person in real life, looking them square in the eyes, then firmly and definitively saying “Fuck you.”

Bottom line is some people rely on browser zoom, and even those that don't expect it to be there. Don't take that away please.

  • Disabling native browser accessibility functions is a really bad idea, a clear ‘F%$K YOU!’ to your users. No-one needs to disable browser zoom. .... +1 – Lodder Jul 2 '15 at 12:46
  • Thank you both for pointing this out. However , I am using Joomla with OpenLayers 3 and having browser zooming and map zooming just ruins everything. I will try to find another work around though to avoid user unfriendliness. – girlintech Jul 2 '15 at 12:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.