View Full Version : Determining if a user is browsing with an iphone.
jcdevelopment
08-21-2008, 04:17 PM
I am probably not wording this right for my search, but i know on some webpages it takes you to an "i" page for example. How does the browser know that you are using an iphone or a mobile device for that matter?
For example, if anyone has one on them, if ou go to yahoo.com, it takes you to a different site for iphones. Does anyone know of a site, or tutorial that i can look at to see? thanks for any suggestions!
abduraooft
08-21-2008, 04:24 PM
They are using a different set of styles by specifying the media attribute in CSS link, see http://www.digital-web.com/articles/css_styling_for_print_and_other_media/
chaosprime
08-21-2008, 08:22 PM
I more frequently see redirection to a mobile-specific site, which is almost certainly done using user agent detection. The user agent string sent by the iPhone browser looks like:Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3
The page you're linking to even describes the handheld media type as mostly useless.
VIPStephan
08-21-2008, 09:07 PM
Nope, no user agent detection. There are some great resources that I’ve promoted recently but which have fallen into oblivion relatively quickly: http://codingforums.com/showthread.php?t=135132
The most important sources for you JC are the ones found at AListApart:
http://alistapart.com/articles/putyourcontentinmypocket
http://alistapart.com/articles/putyourcontentinmypocket2
The trick here is that Safari 3 which is the iPhone browser supports CSS 3 and that includes the advance media attribute values:
<link rel="stylesheet" media="only screen and (max-device-width: 480px)" href="iphone.css" type="text/css" />
tagnu
08-28-2008, 01:37 PM
Someone might find this useful.
Web based iPhone simulator. http://www.testiphone.com/
barkermn01
08-28-2008, 02:18 PM
This is javascript but you just get the browser type witch would be safari browser but the iphone specific i think it can be done give me 10 mins
barkermn01
08-28-2008, 02:21 PM
ok use this code on a page
<script LANGUAGE="JavaScript">
<!-- hide from old browsers
document.write("This browser is version " + navigator.appVersion)
document.write(" of <B>" + navigator.appName + "</B>.")
// end script hiding -->
</SCRIPT>
Then go to this page on your iphone and get the information then use that in if statments E.G
if(navigator.appName == '*iphone appname*' && navigator.appVersion == '*iphone appVersion*')
{
// do you iphone code
}else{
// dp you code for normall browser
}
abduraooft
08-28-2008, 02:56 PM
javascript methods are not reliable, everyone may not have javascript support in their browser.
barkermn01
08-29-2008, 08:51 AM
javascript methods are not reliable, everyone may not have javascript support in their browser.
What Do you own an IPhone, if so try dissabling JS on it it would break every application on the phone unless jailbroken as the applications are web application so most of them use javascript
EDIT:::
Sorry just to be clear by applications i meen software you have downloaded from the apple downloader to the phone with the latest software
EDIT:::
and there is only 2 ways to hand differnt browser info one is .htaccess - witch is not easy to use
and the other is javascript no other methords of getting browser info
and if you say ASP.NET i will screem as ASP.NET will show you i nice little way but will use javascript to send the data to it
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.