js判断访问媒体介质

<script type="text/javascript">
  var userAgent = navigator.userAgent.toLowerCase(),
  userTerminal = userAgent.match( /ipad/i ) ||
  userAgent.match( /iphone os/i ) ||
  userAgent.match( /midp/i ) ||
  userAgent.match( /ucweb/i ) ||
  userAgent.match( /android/i );
   
  if( userTerminal == ‘ipad‘ )
  {
  document.write( ‘<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-capable" content="yes">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-status-bar-style" content="black">‘);
  }
  else if( userTerminal == ‘iphone os‘ )
  {
  document.write( ‘<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-capable" content="yes">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-status-bar-style" content="black">‘ );
  }
  else if( userTerminal == ‘midp‘ )
  {
  document.write( ‘<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-capable" content="yes">‘ );
  document.write( ‘<meta name="apple-mobile-web-app-status-bar-style" content="black">‘ );
  }
  else if( userTerminal == ‘android‘ )
  {
  document.write( ‘<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">‘ );
  };
  </script>

js判断访问媒体介质,布布扣,bubuko.com

js判断访问媒体介质

上一篇:JS:指定FPS帧频,requestAnimationFrame播放动画


下一篇:[ORACLE]oracle 如何解决高水平线问题