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?
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.
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.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With