Solved

html or java script to detect the mobile phone access

Posted on 2010-09-15
14
766 Views
Last Modified: 2012-05-10
Is there a html or java script to detect the mobile phone access and re-direct user to a mobile phone site?
0
Comment
Question by:netthing
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
14 Comments
 
LVL 40

Expert Comment

by:gurvinder372
ID: 33684137
You can check the user-agent field in the request header and invoke the corresponding site.
http://en.wikipedia.org/wiki/List_of_HTTP_header_fields
http://en.wikipedia.org/wiki/User_agent
0
 
LVL 1

Expert Comment

by:Simon-H
ID: 33684168
Simon-H:
http://www.quirksmode.org/js/detect.html

You can then place a query that will redirect the page based on the response your code receives from the detection.

Regards,

Simon
0
 

Author Comment

by:netthing
ID: 33685227
thanks to both of you but unfortunely we are not code people and were looking for an actual script that would do as you suggested. To muddy the waters a little we would like the high end phones (iphone, android based) to view the main site while the low end/older phones would be redirected to a mobile site.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Expert Comment

by:Simon-H
ID: 33685292
can you give me the two links?
0
 

Author Comment

by:netthing
ID: 33685783
Not sure what links you want but the primary website is underdevelopment eg: www.yourburiness.com and the redirect would be to m.yourbusiness.com. Is that the information you need?

Thanls
0
 
LVL 1

Expert Comment

by:Simon-H
ID: 33685825
yes that's what I was after, sorry for the poor explination!

I will have a look at the script and get back to you shortly.
0
 
LVL 1

Expert Comment

by:Simon-H
ID: 33686141
I've attached a php script, courtesy of http://detectmobilebrowsers.mobi/ 

It needs a slight be of personalisation as you require it (for iphone, ipad, android, other smartphone, etc.)
There is an explination as to how to do this within the text file.

When you are done editing, you will need to rename the file, removing ".txt" so it will just be called "mobile_device_detect.php" then you can intergrate it to your homepage.

I am assuming that your web server support php (Hypertext Preprocessor).

If you have any problems with this please let me know and I will take a look for you tomorrow.

Regards,

-Simon
mobile-device-detect.php.txt
0
 

Author Comment

by:netthing
ID: 33687374
unfortunately we already looked at using php script. besides the new site, for which that script would be no problem, we also want to apply it to several existing sites. the sites use html pages with ssi for headers, navigation and footers. to use a php script would require us to recode all the pages so that the ssi will display correctly. this is why we were wondering if there was a java script that would do the same thing as that php script.

thanks
0
 
LVL 1

Expert Comment

by:Simon-H
ID: 33690015
Try placing this script within your head tags on your home page (http://www.yourburiness.com/)

This should redirect iphone, ipad and ipod to "i.yourbusiness.com" and mobiles to "m.yourbusiness.com"

Let me know how you get on with this.

Regards,
script.txt
0
 

Author Comment

by:netthing
ID: 33691940
I tried it on a test site and the code shows at the top of the html page, see the attached image
Untitled-1.jpg
0
 
LVL 1

Expert Comment

by:Simon-H
ID: 33692525
That's odd. It's works fine on my webserver.

Are you able to post a link to the test page? I'm unable to read it, as it's a bit blury.
0
 

Author Comment

by:netthing
ID: 33696231
http://www.netthing.net/index_m.html

the issue, as I understand it, is trying to run a php script in on a html site
0
 
LVL 1

Accepted Solution

by:
Simon-H earned 125 total points
ID: 33702618
no, please deregard the php script and just use the js one I posted last;

"script.txt"
0
 

Author Closing Comment

by:netthing
ID: 33703695
thanks for the assistance
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
javascript works in Chrome, but none of the other browsers 14 54
Editing .asp website 5 35
Automatic field translation delphi 10.2 6 46
Today Date 3 10
This article discusses four methods for overlaying images in a container on a web page
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

710 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