I am working on web analytics, I have to find out the os of the visitor specific with following conditions
1.Cross-browser compatibility.
2.For all devices(tablet,iphone,mobile,deskstop,etc).
3.Maximum possible accuracy.
I have referred some questions regarding os detection, Answer is navigator.platform but it does not supported for some devices
Note: we cannot rely on useragent as well.
Any suggestion will be greatful.
In case it could be PHP instead of JavaScript; this piece of code is so reliable and accurate and have been tested on many devices -mobile devices- and it works like charm:
preg_match("/(android|avantgo|blackberry|nokia|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
this only detects mobile devices but you can tweak the code in different way to get what you need.
Also check this link >> php to detect browser and operating system - which contains PHP codes too.
Related
I've tried on getting browser info from javascript - navigator.userAgent, but cannot find any related string with "Vivaldi".
Please help to suggest if there are any other programming method or javascript can be used to detect Vivaldi browser?
The correct syntax in JavaScript is navigator.userAgent.
You can check window size, but it may be incorrect.
Vivaldi has its own sidebar and bottom bar that the others not.
But remember, user can change the window size to prevent detection.
According to Vivaldi, the userAgent will not have Vivaldi in it for a better user experience and mimic Chrome in all sites except a few known ones.
For the next release of Vivaldi, we have decided to try something different. The problem with our current approach is that with the web being almost infinite, we can’t possibly discover all the websites who have blocks set against us. Thus maintaining a list of sites where we present a non-Vivaldi User Agent is difficult. Instead, we will try doing the reverse. For a handful of sites where we know the label Vivaldi (and our version number) is responsibly used, we will present our full User Agent. Those sites being our own and a handful of interesting alternative search engines: duckduckgo.com, ecosia.org, qwant.com, and startpage.com. Every other site will get a User Agent that appears to be identical to Chrome.
src: https://vivaldi.com/blog/user-agent-changes/
Since you haven't mentioned your use case, assuming you are building sites, the best solution would be to do what everyone does. I recommend building websites agnostic to browsers and devices, but responsive to resolutions and feature support. Almost all of the browsers are running on Chromium these days, except Safari and Firefox (to my knowledge). So they are all going to work consistently across the board. For any given feature, one could always refer to w3c or mdn docs for compatibility and build around that.
Browser detection is also not quite reliable, as there are extensions to spoof the information. Like this extension that mimics a TV agent so one can run youtube console version on it.
On the other hand, once again I don't know your use case, one might benefit from platform detection over browser detection, like catering to mobile and TV users. Even then, if you have a site responsive enough the platform becomes non-essential information.
Is there any way to detect whether a mobile device is capable of making voice calls / SMS messages?
This is important when applying tel: and sms: links in a web page. It is not enough to merely detect mobile, since tablets can't make calls, iTouch can't make calls, etc.
I'm not interested in mobile detection hacks using device size, UA string detection, etc. I want to use feature detection to determine if the device is capable of voice calls / SMS text messaging. I'd love a universal solution, but am mainly interested in iOS / Android.
I havent seen an obvious way to see that sms: and tel: links get special treatment.
Update: #janogosteve below has confirmed there is currently no reliable feature detect. This looks undetectable.
Here's a comprehensive way to check this feature detect. (Read jangosteve comment below!)
make a test page with two of those links and a regular http link
grab the elements and then traverse all their properties, copy it all over to an object..
also getComputedStyle info for a bunch of details on them and throw that into an object as well
JSON.stringify( that stuff so you can deal with it later on)
Do the above on an iOS device and in desktop Safari/Chrome
Then JSON.parse them back into objects... and use https://github.com/NV/objectDiff.js to see if you can spot any differences at all.
A new plot twist in this problem (as of Feb 2015) is that many desktop browsers now support click-to-call, however they won't auto-detect phone numbers.
So the nifty tricks floating around for sniffing out phone number auto-detection or touch capability, are now obsolete.
Mac OSX since Yosemite 10.9.2 has supported click-to-call with Facetime audio, and Windows 8 / IE11 does the same using Skype. Not sure about Chrome OS (Hangouts?). iPads use Facetime audio calls.
It looks like all web browsers from now onwards will support click-to-call. The question is really about how to prevent older browsers and desktop OS users from getting an error when clicking a tel: link.
I made a Javascript library to attempt to detect older desktop OS users that are before tel: link support, but it proved very problematic and complicated.
Right now my approach is either:
A) Leave it as a link for all users. Users without a call-capable browser will just have to suffer
B) Use a media query to hide the link styling for only desktop browser widths, assuming that most desktop users aren't going to be
making calls from their desktop PC anyhow.
C) Skip the <a> tag and desktops altogether and let auto-detection do it's link magic on mobile devices
I'm not crazy about any of these solutions, but I'm opting for B until the browser support landscape changes in the future. That way I have control over the <a> tag, a desktop user can still click the phone # if they really want to, and I can swap easily in the future.
I'm developing an HTML / Javascript application meant to run on an Android device running Froyo (2.2). Assuming I don't need multitouch functionality, will the emulator's browser be a reliable means of debugging HTML, CSS and Javascript? Or is it possible that I would work out all the bugs in the emulator but find the actual device handles things differently?
The underlying code for WebKit is identical in the emulator and the actual device. The only thing you need to worry about are the other components inbetween (some carriers have proxies, for example. I used to have problems with T-Mobile where it would simply send me a outdated cached version of a site instead of even contacting the site).
I know this is a bit of perennial question, but here goes: I want to know whether the device my site is being accessed with is a touchscreen. That means phones and iPads, of course, which are individually detectable, but also other touchscreens that may well be running flavors of Windows. Any chance of determining the presence or absence of a mouse on those?
Let's say I'm willing to use a large JavaScript library like Modernizr. Will that help any?
You might want to look into MobileESP. Not touchscreens only, but it at least gives you some detection capabilities. From their page:
The MobileESP project seeks to provide
web site developers an easy-to-use and
lightweight API for detecting whether
visitors are using a mobile device,
and if so, what kind. The APIs provide
simple boolean results for popular
individual device OS categories (such
as iPhone, BlackBerry, Symbian S60,
and Windows Mobile), device
capabilities (e.g., J2ME), and broad
classes of devices, such as "iPhone
Tier" (iPhone/Android/WebOS) and
smartphones.
Try http://wurfl.sourceforge.net/ for device capabilities.
Does javascript work on mobile phones?
Which mobile phones?
There's some pretty good information on this site:
http://www.quirksmode.org/m/table.html
depends on the browser
Some. Do you have a specific model in mind or just in general?
Depends on what mobile phones and to what extent you need support.
Smart phones pretty much all include support for JavaScript. How well they support them is another story.
You can see a lot of what mobile devices support here: http://www.quirksmode.org/m/table.html
In general I would assume that javascript isn't there, as older cellphone models may not support javascript, but, if you use unobtrusive javascript and graceful degradation, then it won't really matter, as your page will function in some known way on any device, as long as it is formatting itself properly.
So, if you want to have it work on all mobile phones, then start with not needing javascript, then add in the javascript as an enhancement.
Bare in mind as well that their are different versions of JavaScript supported by different phones and different browsers, even if JavaScript is available.
http://www.skyfire.com/ if you can get that browser on it then you can get javascript! Awesome browser and quite portable...
Works on Symbian (Nokia Phones use it) and Windows Mobile.
I think javascript is totally browser dependent. Symbian mobile surely can run javascript. Smart phones are much smarter to handle javascript.