![](/img/trans.png)
[英]What design technique to apply in order to match PC, tablet and smarthphone?
[英]Sencha Touch how to load custom CSS , JS if user is using PC or Tablet or SmarthPhone?
如何設置頁面,以便當用戶使用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
例:
<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 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.