-2

I am a beginner and i am learning javascript.

I have a doubt, is it possible to disable the browser zoom which exists in the menu section of the browser. I have been able to disable the zoom that occurs when using ctrl + mouse scroll and any key event that occurs. But is there a way to disable / a way to block the browser independent zoom options given in their respective menus.

Thanks in advance!

Sidharth
  • 79
  • 1
  • 2
  • 9
  • 1
    have a look at this: [prevent-zoom-cross-browser](http://stackoverflow.com/questions/27116221/prevent-zoom-cross-browser) – Kevin Kloet Nov 03 '16 at 11:21
  • 3
    Why would you want to do that? Seems to me like it wouldn't necessarily achieve that much except for taking away a useful accessibility option. – JVDL Nov 03 '16 at 11:25
  • 1
    For many people the zoom is to help them see the page. Circumventing the zoom will simply prevent these people from being able to view your page. Plus what is the difference between a zoomed page and a page on a low res monitor? – Blindman67 Nov 03 '16 at 11:34
  • 1
    Don't underestimate how important the zoom feature is to some people. I had to redo a massive chunk of my app's CSS at work last year because one of our customers was legally blind and the UI didn't handle being zoomed well. – Joe Clay Nov 03 '16 at 11:34

2 Answers2

3

I believe that it is not possible to achieve this, seeing as most browser zoom functions are most definitely hard coded and forced.

The only (cheaty/somewhat regretful) solution that I've seen being used is the following:

  <script>
      document.firstElementChild.style.zoom = "reset";
  </script>

(Which you could easily put as css too). Disabling zoom is not the best solution. Especially if the project that you are working on possibly consists of a lot of text. Zooming function adds readability and increases accessibility to your website, especially for aid of those with bad sight.

1

I'm pretty sure this isn't possible, and for good reason. It seems like disabling the zoom shortcut is the best you can do. However, the user can still:

  • Zoom in using browser menu,
  • Take a screenshot and zoom in, etc.

Basically, disabling a user's zoom is not achievable in any major browsers (ie, Chrome and Firefox). There will always be some type of workaround. However, if you edit your question and tell us why you want to disable the zoom, we might be able to help you find a workaround for the purpose you need.

mancestr
  • 969
  • 3
  • 13
  • 34
  • Hey Zack, I understand your point. Why do i want to do is ? I dont want the elements to increase or decrease their size as and when the zoom in & out happens. So this is what i want to do, how do i do it? – Sidharth Nov 03 '16 at 11:35
  • 2
    @Sidharth- I'm sorry to state the obvious, but people zoom because the element is too small to see. If someone's using a smaller screen, zooming may be the only way they can see the site, and removing that function would hurt their experience on the website. Also, I understand that you want to keep the elements from resizing, but why? Is there a good reason? – mancestr Nov 03 '16 at 13:56