Created
January 28, 2019 01:24
-
-
Save ClausClaus/f4e39a622b5c55aa7cb0e55848983e55 to your computer and use it in GitHub Desktop.
dpi设置
This file contains 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
(function () { | |
var width = parseInt(window.screen.width) | |
var designWidth = 450 | |
var scale = width / designWidth | |
var userAgent = navigator.userAgent.toLowerCase() | |
var metaHead = '<meta name="viewport" content="width=' + designWidth + ',' | |
if (/android (\d+\.\d+)/.test(userAgent)) { | |
if (parseFloat(RegExp.$1) > 2.3) metaHead += 'minimum-scale=' + scale + ',maximum-scale=' + scale + ',' | |
} else { | |
metaHead += 'user-scalable=no,'; | |
} | |
metaHead += 'target-densitydpi=device-dpi">'; | |
document.write(metaHead); | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment