Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何识别设备类型,Phone, Tablet(Pad) 和 Desktop ? #42

Open
hotoo opened this issue Nov 21, 2013 · 7 comments
Open

如何识别设备类型,Phone, Tablet(Pad) 和 Desktop ? #42

hotoo opened this issue Nov 21, 2013 · 7 comments

Comments

@hotoo
Copy link
Owner

hotoo commented Nov 21, 2013

  • 按照 UA 识别『不准确』
  • 按照分辨率区分『不准确』
  • 按照物理尺寸『无法获得 DPI,可以结合 CSS 但不准确』
  • 按照有无 3G通信模块『无法获得』

参考

@hotoo hotoo added the reference label Jul 8, 2014
@hotoo hotoo changed the title 如何识别设备类型,Phone 和 Pad ? 如何识别设备类型,Phone, Tablet(Pad) 和 Desktop ? Jul 8, 2014
@hotoo hotoo added the question label Aug 15, 2014
@fredshare
Copy link

可以增加苹果系列的区分,3、4、5、6可以通过屏幕高度window.screen.height辅助window.devicePixelRatio来判断。比如:

                var iosVersioin;
                if (detector.device.name == "iphone") {
                    var height = screen.height;
                    if (height == 480) {
                        iosVersioin = "4、4s"
                    } else {
                        if (height == 568) {
                            iosVersioin = "5、5s、5c"
                        } else {
                            if (height == 667) {
                                if(window.devicePixelRatio == 3){
                                    iosVersioin = '6 plus';
                                }else{
                                    iosVersioin = "6"
                                }

                            } else {
                                if (height == 736) {
                                    iosVersioin = "6 plus"
                                } else {
                                    iosVersioin = "unkown"
                                }
                            }
                        }
                    }
                }

@airyland
Copy link

希望增加iPhone 4,5,6的检测

@hotoo
Copy link
Owner Author

hotoo commented Apr 22, 2015

什么用途?

@airyland
Copy link

记录,用户反馈问题时可以知道是哪个型号的问题。日常error也可以快速找测试机来检查。

@hotoo
Copy link
Owner Author

hotoo commented Apr 22, 2015

一般跟硬件关系不大吧,主要看操作系统、浏览器及渲染引擎的软件。

@airyland
Copy link

不是大家都需要这个,那我们就自己实现一下就好了。

@hotoo
Copy link
Owner Author

hotoo commented Apr 22, 2015

嗯。还没想清楚,detector 暂时还没有加入这个功能的计划。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants