【问题标题】:How to know which device is on the website?如何知道网站上的设备是什么?
【发布时间】:2015-07-05 09:12:06
【问题描述】:

我最近做了一个 javascript 游戏,但是它拒绝在手机和 iPad 上运行...

有没有办法知道用户是否使用PC,以便我可以阻止移动用户尝试它?

【问题讨论】:

标签: web mobile responsive-design


【解决方案1】:

您可以将媒体查询用于响应式 UI,并查看以下代码:

 // For Smartphone
            if (window.innerWidth < 600)
            {
                // TODO-- for the SmartPhone
            }

            // For Tablet
            else if(window.innerWidth > 600 && window.innerWidth < 768)
            {
                //TODO-- for the Tablet.
            }

            // For Desktop
            else if(window.innerWidth > 768)
            {
                //TODO -- for the Desktop.
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-02-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-25
    • 1970-01-01
    • 1970-01-01
    • 2011-09-15
    相关资源
    最近更新 更多