关于javascript:Sencha如果用户使用PC或Tablet或SmarthPhone,如何触摸如何加载自定义CSS,JS?

Sencha Touch how to load custom CSS , JS if user is using PC or Tablet or SmarthPhone?

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


我认为最好,最干净的解决方案是在服务器端添加此功能。检查用户代理请求标头,以确定要发送的文件。您还可以重定向到其他子域,例如到m.example.com。但是,如果要使用sencha进行操作,请阅读此文章:http://www.sencha.com/learn/idiomatic-layouts-with-sencha-touch


也许您必须为此

使用media query

检查此http://css-tricks.com/snippets/css/media-queries-for-standard-devices/

http://css-tricks.com/6206-resolution-specific-stylesheets/


示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<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"
        }