Solved

detecting if a visitor is on a mobile device

Posted on 2011-03-23
5
526 Views
Last Modified: 2012-05-11
Hi,

I am struggling to find a definative answer to my question which I know is well used.

Basically I have a flash file on my website.

I want to add some code to my vb.net page that can tell if the user is from a mobile device and if so just make the flash invisible and replace it with an image.

What is the best way to do this so I don't have to worry about specific devices etc like ihpone and so on.....?

Thanks in advance
0
Comment
Question by:scm0sml
  • 3
  • 2
5 Comments
 
LVL 6

Accepted Solution

by:
HyperBPP earned 500 total points
ID: 35199863
0
 

Author Comment

by:scm0sml
ID: 35199979
ok so if i wanted to do it in code rather than using the webconfig:
context.Request.ServerVariables["HTTP_USER_AGENT"] =

what would i need to check for just to see if it is a mobile device rather than worrying about the manufacturer etc as it is in the code behind that I will need my code to hide the image?
0
 
LVL 6

Expert Comment

by:HyperBPP
ID: 35200362
Surround the Flash content with an "if" statment similar to:

if(isMobileBrowser() = false) then
    <flash stuff here>
end if
0
 

Author Comment

by:scm0sml
ID: 35200509
You're missing my point.

What goes after the = in my previous post?
0
 
LVL 6

Expert Comment

by:HyperBPP
ID: 35200707
You are going to have to loop over several values to find out if the HTTP_USER_AGENT is a mobile device.  I personally would use a HashTable to store the values listed below, and use:

if(hashTableVar.containsKey(context.Request.ServerVariables["HTTP_USER_AGENT"]) = False) then
    ...Flash stuff...
end if


If HTTP_USER_AGENT is equal to any of the following values then it is a mobile device:

“midp”, “j2me”, “avant”, “docomo”,
“novarra”, “palmos”, “palmsource”,
“240×320¿, “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”


This site has a listing of mobile browser user_agent strings:  http://www.zytrax.com/tech/web/mobile_ids.html.

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Contant UI messages in .NET 1 41
Azure Web App - See files 3 21
ASP.net VB.net Email  a webpage 3 26
Entity Framework 3 11
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now