【问题标题】:Sencha Touch how to load custom CSS , JS if user is using PC or Tablet or SmarthPhone?如果用户使用 PC 或平板电脑或 SmarthPhone,Sencha Touch 如何加载自定义 CSS、JS?
【发布时间】:2011-10-12 08:41:52
【问题描述】:

如何设置页面,所以当用户使用 Pc(Safari/Chrome/Firefox) 时,用户获得“正常”网页,但是当他使用“ipad”查看相同的 URL 时,他获得 Sencha Touch(css, js) 文件到他的浏览器? JavaScript 浏览器检测,导航器?还是 Sencha 对此有本机解决方案?我知道Ext.env.Browser,但用户可以在 PC 和 IPAD 上使用 Safari 吗?有任何想法吗?谢谢!

【问题讨论】:

    标签: javascript css ipad sencha-touch navigator


    【解决方案1】:

    我认为最好和最干净的解决方案是在服务器端添加此功能。检查用户代理请求标头以决定要发送哪些文件。您还可以重定向到不同的子域,例如到 m.example.com。但如果你想用煎茶来做,那么请阅读这篇文章:http://www.sencha.com/learn/idiomatic-layouts-with-sencha-touch

    【讨论】:

    • 谢谢,这个想法是检查女巫“设备”是用户使用然后加载不同的 index.html,或者决定女巫
    • 你有这方面的例子吗?
    【解决方案2】:

    【讨论】:

    • @sandeep- 谢谢,但我真正需要的是
    【解决方案3】:

    例子:

    <script type="text/javascript">
    
        var isiPad  = navigator.userAgent.match(/iPad/i) != null;   
        var isiPhone    = navigator.userAgent.match(/iPhone/i) != null; 
    
            if(isiPad){
                alert("Ipad");
                //window.location = "http://www.google.com/iPad/"
            }if(isiPhone){
                alert("Iphone");
                //window.location = "http://www.google.com/iPhone/"
            }else{
                window.location = "http://www.google.com"
            }
    
    </script>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-24
      • 2013-09-23
      • 2012-12-06
      • 1970-01-01
      • 2011-09-29
      • 2017-12-20
      • 1970-01-01
      相关资源
      最近更新 更多