admin管理员组文章数量:1391947
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?
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?
Share Improve this question asked May 12, 2011 at 11:49 user750487user750487 1,0632 gold badges12 silver badges13 bronze badges 3- 3 As 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 Commented May 12, 2011 at 11:52
- Similar question: stackoverflow./questions/2578354/… – stivlo Commented May 12, 2011 at 11:58
- This is client request... Not my :) – user750487 Commented May 12, 2011 at 12:05
3 Answers
Reset to default 1I 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>
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.
you can use
document.body.style.zoom
also in CSS :
element{zoom:<value>;}
本文标签: javascript page zoomStack Overflow
版权声明:本文标题:javascript page zoom - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744704927a2620785.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论