Sencha Touch如何加载自定义CSS, JS,如果用户使用PC或平板电脑或智能手机

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

本文关键字:用户 如果 JS PC 智能手机 平板电脑 CSS 何加载 Touch 自定义 加载      更新时间:2023-09-26

如何设置页面,以便当用户使用Pc(Safari/Chrome/Firefox)时,用户获得"正常"网页,但当他使用"ipad"查看相同的URL时,他获得Sencha Touch(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/

示例:

<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>
相关文章: