Search code examples
javascriptcssscale

Changing page scale via javascript


I wish to scale the body of my website acording to resolution, but the code not seems to work:

document.body.style.transform: scale(window.screen.availHeight/2);
document.body.style['-o-transform'] = window.screen.availHeight/2;
document.body.style['-webkit-transform'] = window.screen.availHeight/2;
document.body.style['-moz-transform'] = window.screen.availHeight/2;

Solution

  • Try

    document.body.style.transform = 'scale(' + window.screen.availHeight/2 + ')';
    document.body.style['-o-transform'] = 'scale(' + window.screen.availHeight/2 + ')';
    document.body.style['-webkit-transform'] = 'scale(' + window.screen.availHeight/2 + ')';
    document.body.style['-moz-transform'] = 'scale(' + window.screen.availHeight/2 + ')';