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?
Asked
Active
Viewed 9,384 times
6
-
3As you pointed out, browsers have this feature built in. Why do you feel the need to simulate it with a UI that users' won't be familier with? – Quentin May 12 '11 at 11:52
-
Similar question: http://stackoverflow.com/questions/2578354/access-browsers-page-zoom-controls-with-javascript – stivlo May 12 '11 at 11:58
-
This is client request... Not my :) – user750487 May 12 '11 at 12:05
3 Answers
1
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>

Kishore Sahasranaman
- 4,013
- 3
- 24
- 50
0
You have apply a logic to retain the current zoom size and increment/decrement parameter to find the required width. You can customize the following function as per your requirement.
function zoom()
{
var wdth = 1024; //Change this variable to match your configuration
document.body.style.zoom = screen.width/1024;
document.Fm.TxAre.value=1024;
alert("1024 ? : "+screen.width/1024);
}
This is just a quick solution. There are lot of better options available in the web. Just thought of sharing an easy method without using third party solution.

Deepu S Nath
- 1,164
- 1
- 17
- 45