Skip to content

Instantly share code, notes, and snippets.

@think2011
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save think2011/a472cdc32676086e78a2 to your computer and use it in GitHub Desktop.
Save think2011/a472cdc32676086e78a2 to your computer and use it in GitHub Desktop.
设置窗口宽度
setViewPort(640);
/**
* 设置窗口宽度
* @param width
*/
function setViewPort(width) {
var scale = window.screen.width / width,
isAndroid = /Android (\d+\.\d+)/.test(navigator.userAgent);
isAndroid
? document.write('<meta name="viewport" content="width=' + width + ', minimum-scale = ' + scale + ', maximum-scale = ' + scale +', target-densitydpi=device-dpi')
: document.write('<meta name="viewport" content="width=' + width + ', user-scalable=no">');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment