0

To improve the user-experience for older Users, who do not know all the functions and shortcuts of their browser, I would like to have a button which simply triggers Ctrl++ (plus-button) to zoom in and improve the readability.

  1. Is this possible?
  2. How?
  3. Is there a solution for Mac-users who do have an other button for Strg?

Edit: Seems like I could use the zoom property in CSS3.

I just tried:

function mzi(){

var oldval = document.getElementById('zoom').style.zoom;
var newval = Number(oldval) + 0.1;

alert('old value is '+Number(oldval)+' and new value is '+newval+'.');
document.getElementById('zoom').style.zoom = Number(oldval) + 0.1;

};

And it almost does what I want.

The problem:

It sets the zoom to 0.1 and not to "oldval + 0.1".

So the problem seems to be somewhere around the variable "oldval".

Maybe I cant store the value correctly or I cant use it correctly?

The alert says old value is 0 and new value is 0.1

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Nils
  • 189
  • 3
  • 13

1 Answers1

0

Hello you can do it like this :

document.addEventListener("keypress", zoom, false);

function zoom(e) {
    var keyId = e.keyCode || e.which;
    if (keyId == 17 && keyId == 107 ) {
        window.parent.document.body.style.zoom += 1.5;// choose the factor of zoom

    }
AngularLover
  • 364
  • 1
  • 12