首页 > 代码库 > js判断访问媒体介质
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> |
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。