Question

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!

Était-ce utile?

La solution

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

Autres conseils

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>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top