Is it possible to change the browser zoom with code?

Asked

Viewed 2,941 times

6

Is there any way to change the browser zoom with JavaScript?

When loading the script would like to change the browser zoom to 100%, can be using any framework (Angular, jQuery).

I’d really appreciate it if you could help.

  • I have a code that works only on IE Eno Chrome, haha! Even if nothing, it can be ?

2 answers

3


Behold this reply (English).

In short it is possible to use:

document.body.style.zoom = 1.0

But this property is not standard for all browsers.

Instead use tranforms instead:

var scale = 'scale(1)';
document.body.style.webkitTransform =  scale;    // Chrome, Opera, Safari
document.body.style.msTransform =   scale;       // IE 9
document.body.style.transform = scale;     // Geral

1

document.body.style.zoom = "200%"
<p>Olá, mundo!</p>

I tested this code in IE and CHROME. However I believe it is Cross-Browser.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.