简体   繁体   中英

How can i zoom out in Firefox?

I have tried to zoom out with follow code:

 window.onload = function () {
     var currFFZoom = 0.99;
     var currIEZoom = 90;

     if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6) { //Firefox
         var step = 0.02;
         currFFZoom -= step;
         $('body').css('MozTransform', 'scale(' + currFFZoom + ')');

     } else {
         var step = 2;
         currIEZoom -= step;
         $('body').css('zoom', ' ' + currIEZoom + '%');
     }

 };

It works in Chrome, but in Mozilla Firefox it doesn't. What Should I do?

You need to change curFFZoom from .99 to .90 like this:

window.onload = function () {
     var currFFZoom = 0.90;
     var currIEZoom = 90;

     if (navigator.userAgent.indexOf('Firefox') != -1 && parseFloat(navigator.userAgent.substring(navigator.userAgent.indexOf('Firefox') + 8)) >= 3.6) { //Firefox
         var step = 0.02;
         currFFZoom -= step;
         $('body').css('MozTransform', 'scale(' + currFFZoom + ')');

     } else {
         var step = 2;
         currIEZoom -= step;
         $('body').css('zoom', ' ' + currIEZoom + '%');
     }

};

If you don't the zoom is too small to notice.

JSFiddle: http://jsfiddle.net/jdwire/YKmrE/2/

您也可以只使用CSS来放大页面加载量:

body { zoom: .9; -moz-transform: scale(0.9); -moz-transform-origin: 0 0 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM