检测小屏幕的最新方法

mpl*_*jan 11 javascript css browser-feature-detection

在等待响应式设计进入遗留网站的过程中,如果屏幕小于480px,我想将浏览器重定向到移动版本

狩猎我想出来了

var isSmall = window.matchMedia ? 
              window.matchMedia("screen and (max-width: 480px)") : 
              screen.width<=480;
Run Code Online (Sandbox Code Playgroud)

这在2014年是否可以接受,或者是否有更好/更安全/更新的方法来做我想要的而不使用useragent嗅探?

参考