开发者

What is the best way to detect mobile screen width using JavaScript

What is the best way to check mobile screen wi开发者_JAVA百科dth using JavaScript? I've tried screen.width but get mixed results.


Modernizr would be a good tool for you to use. Have a look at the mq() function (media query). It uses the CSS @media tag to evaluate media types and screen sizes.


You can use the Javascript mobile detection method at HandsetDetection.com. Create a site profile with no redirection rules and embed the detection javascript in your page. Then you can access the HandsetDetection.width and HandsetDetection.height variables directly from javascript for screen resolution.

Hope that helps.

(Disclaimer: I work there).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜