Possible Duplicate:
How to detect page zoom level in all modern browsers?
var obj=document.body; // obj=element for example body
// bind mousewheel event on the mouseWheel function
if(obj.addEventListener)
{
obj.addEventListener('DOMMouseScroll',mouseWheel,false);
obj.addEventListener("mousewheel",mouseWheel,false);
}
else obj.onmousewheel=mouseWheel;
function mouseWheel(e)
{
// disabling
e=e?e:window.event;
if(e.ctrlKey)
{
if(e.preventDefault) e.preventDefault();
else e.returnValue=false;
return false;
}
}
I am developing a web app and all ui element will be not in a correct order if user zoom in / zoom out . So, are there any way to prevent it? I have think of some way to do it but is it possible ?
1) Get the screen resolution of the user. When the window size is change (either width or height), return the window width/height to screen width /height.
2) bind the mouse scroll event or keyboard event to nothing. (Refer to above demo code) , but what if the user click on the browser and select zoom in ?
Thanks
var zoomlevel=1;
$("body").dblclick(function(ev) {
zoomlevel = zoomlevel == 1 ? 2 : 1;
$(this).css({
"-moz-transform":"scale("+zoomlevel+")",
"-webkit-transform":"scale("+zoomlevel+")",
"-o-transform":"scale("+zoomlevel+")",
"-ms-transform":"scale("+zoomlevel+")"
});
});
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