2012-06-28 27 views
0

我試圖將移動設備重定向到移動版本,但讓Ipad正常查看它。所有手機重定向到移動網站罰款,但ipad也是,我不知道爲什麼?... 這是我使用的腳本。重定向到移動網站,除了ipad java

<scr!pt runat="server"> 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     string[] mobiles = new string[] {"midp", "j2me", "avant", "docomo","novarra", 
      "palmos", "palmsource","240x320", "opwv", "chtml","pda", "windows ce", 
      "mmp/","blackberry", "mib/", "symbian","wireless", "nokia", "hand", 
      "mobi","phone", "cdm", "up.b", "audio", "SIE-", "SEC-", "samsung", 
      "HTC","mot-", "mitsu", "sagem", "sony","alcatel", "lg", "eric", "vx","NEC", 
      "philips", "mmm", "xx","panasonic", "sharp", "wap", "sch","rover", "pocket", 
      "benq", "java","pt", "pg", "vox", "amoi","bird", "compal", "kg", "voda","sany", 
      "kdd", "dbt", "sendo", "sgh", "gradi", "jb", "dddi","moto", "iphone" }; 
    bool isMobile = false; 

    if (Request.Headers["User-Agent"] != null && Request.Browser["IsMobileDevice"] == "true") 
    { 
     isMobile = true; 
    } 
    else 
    { 
     foreach (string device in mobiles) 
     { 
      if (Request.UserAgent.ToLower().Contains(device)) 
      { 
       isMobile = true; 
      } 
     } 
    } 

    if (isMobile == true) 
    { 
     Response.Redirect("///SITE//"); 
    } 
    else 
    { 
     Response.Redirect("//SITE//"); 
    } 
} 

回答

0

這個問題What is the iPad user agent?表明的ipad發送其用戶代理字符串中包含字符串iPhone。所以數組中的最後一個字符串會將其跳過。

也許你可以做反向,即如果USer-Agent包含ipad重定向到正常站點?

希望有更多ipad經驗的人能夠提供更多見解。