Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

javascript page zoom

Tags:

javascript

Hi i develop my web site and i want to make two buttons (+ and -) with functions of ctr+ and ctr- for zoom in and zoom out of whole web page in all browsers. I need javascript code for this purpose Can anybody help?

like image 324
user750487 Avatar asked May 12 '11 11:05

user750487


People also ask

How do I zoom in JavaScript?

In order to zoom images in and out in JavaScript, you need to either change the width and height properties of the img element, or you need to use transform: scale() . The easiest way to do this is to apply a class to the element with JavaScript.

Can JavaScript detect the browser zoom level?

Method 1: Using outerWidth and innerWidth Property: It is easier to detect the zoom level in webkit browsers like Chrome and Microsoft Edge. This method uses the outerWidth and innerWidthproperties, which are the inbuilt function of JavaScript.


1 Answers

I hope this helps you ! This will zoom the entire body tag

var currentZoom = 100;
function zoom(paramvar)
{
  currentZoom += paramvar;
  document.body.style.zoom =  currentZoom + "%" 
}
<button onclick="zoom(+10);">Zoom In</button>
<button onclick="zoom(-10);">Zoom Out</button>
like image 103
Kishore Sahasranaman Avatar answered Oct 05 '22 11:10

Kishore Sahasranaman