Created
October 20, 2013 06:07
-
-
Save maxlee/7065530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var detectZoom = function(){ | |
| var ratio = 0, | |
| screen = window.screen, | |
| ua = navigator.userAgent.toLowerCase(); | |
| if( ~ua.indexOf('firefox') ){ | |
| if( window.devicePixelRatio !== undefined ){ | |
| ratio = window.devicePixelRatio; | |
| } | |
| } | |
| else if( ~ua.indexOf('msie') ){ | |
| if( screen.deviceXDPI && screen.logicalXDPI ){ | |
| ratio = screen.deviceXDPI / screen.logicalXDPI; | |
| } | |
| } | |
| else if( window.outerWidth !== undefined && window.innerWidth !== undefined ){ | |
| ratio = window.outerWidth / window.innerWidth; | |
| } | |
| if( ratio ){ | |
| ratio = Math.round( ratio * 100 ); | |
| } | |
| // 360安全浏览器下浏览器最大化时诡异的outerWidth和innerWidth不相等 | |
| if( ratio === 99 || ratio === 101 ){ | |
| ratio = 100; | |
| } | |
| return ratio; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment