How to setup page so when user is using Pc(Safari/Chrome/Firefox), user gets "normal" web page, but when he is using "ipad" to view the same URL, he gets Sencha Touch(css,js) files to his browser? JavaScript Browser Detection,navigator? Or Sencha has native solution for this? I know about Ext.env.Browser but user can have Safari on PC and IPAD? Any ideas? Thanks!

有帮助吗?

解决方案

I think the best and the cleanest solution is to add this functionality on the server side. Check the user-agent request header to decide which files to send. You can also redirect to different sub domain, e.g. to m.example.com. But if you want to do it with sencha then read this article: http://www.sencha.com/learn/idiomatic-layouts-with-sencha-touch

其他提示

Example:

<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>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top