Ber*_*ert 8 html javascript css php jquery
谁能帮我这个.
我想检测诸如Iphone,BB,andriod和浏览器之类的设备,以应用它们的特定css使其液化或调整到它们的分辨率.
Andriod和Iphone在移动浏览器方面有不同的分辨率问题或css问题,因为我打算为那些2使用相同的css,因为我知道他们使用相同的浏览器safari作为默认.
以下是javascript中的示例:
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry)/);
if(isMobile) {
// User-Agent is IPhone, IPod, IPad, Android or BlackBerry
}
Run Code Online (Sandbox Code Playgroud)
要检查特定的User-Agent字符串,您可以执行以下操作:
if(navigator.userAgent.match(/iPhone/)) {
// The User-Agent is iPhone
}
Run Code Online (Sandbox Code Playgroud)
尝试使用http://www.php.net/get_browser并检查isMobileDevice
字段。browscap.ini
当然,只有在 php.ini 中设置了 php.ini 的路径时,它才可能有帮助。如果没有,您可以使用 php 类,例如https://github.com/garetjax/phpbrowscap