DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Page Zoom With Javascript

10.20.2009
| 9082 views |
  • submit to reddit
        
var size = 1;
var factor = 0.95;
var lo = 0.5;
var hi = 1.7;
function sizechange() {
  var body = document.getElementsByTagName('body')[0];
  if (size <= lo) {
     factor = 1.05;
  }
  if (size >= hi) {
     factor = 0.95;
  }
  size = size * factor;
  body.style.fontSize = '' + size + 'em';
  setTimeout('sizechange()', 100);
}
window.onload = sizechange;
    

Comments

Arvind Bhardwaj replied on Wed, 2012/11/28 - 1:19am

This script zooms only the text content on the page. Other page elements like images, tables, divs are not zoomed.