javascript - How to find device type whether is it a computer or mobile in vb.net with SQL Server -
i have project in need know device type (computer or mobile). have searched everywhere cannot find answer.
i'm using below function check mobile browser or not? otherwise it's computer browser.
public shared function ismobilebrowser() boolean 'gets current user context dim context httpcontext = httpcontext.current 'first try built in asp.nt check if context.request.browser.ismobiledevice return true end if 'then try checking http_x_wap_profile header if context.request.servervariables("http_x_wap_profile") isnot nothing return true end if 'then try checking http_accept exists , contains wap if context.request.servervariables("http_accept") isnot nothing andalso context.request.servervariables("http_accept").tolower().contains("wap") return true end if 'and check http_user_agent 'header variable 1 of following if context.request.servervariables("http_user_agent") isnot nothing 'create list of mobile types dim mobiles 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", _ "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"} ' "nec", 'loop through each item in list created above 'and check if header contains text each s string in mobiles if context.request.servervariables("http_user_agent").tolower().contains(s.tolower()) return true end if next end if return false end function
Comments
Post a Comment