Solved

detecting if a visitor is on a mobile device

Posted on 2011-03-23
5
532 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

809 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