how can a website detect smartphone model? [duplicate] - javascript

This question already has answers here:
Simple Smart Phone detection
(2 answers)
Closed 9 years ago.
How can a website detect the smartphone model of a device that requests a webpage?
Google Analytics can get that information as you can see in the image below:
I found this: http://blog.mobileesp.com/?p=177 but only a few phones are recognized by this script. I am looking for an PHP or Javascript solution

From Javascript you can read this property navigator.userAgent and PHP $_SERVER['HTTP_USER_AGENT'] both return you the browser version .

In my experience, the best method for detecting mobile/tablet is to use the PHP mobile_detect class which is updated regularly as new devices are released. Unfortunately, I don't know if it provides a way to get the different device types.
User agent parsing is the method you'll have to use, and if mobile_detect doesn't have it, it ought to at least give you a good starting point on how it's done.

Related

Capture Image from Webcam through js/JavaScript [duplicate]

This question already has answers here:
How can I capture an image via the user's webcam using getUserMedia?
(3 answers)
Closed 2 years ago.
I am looking to capture the image from the webcam.
I have tested quite a few libraries including
https://github.com/jhuckaby/webcamjs
https://github.com/amw/jpeg_camera
But all existing libraries are very old and no longer maintained by authors.
I have also tried "navigator.mediaDevices.getUserMedia" to capture the image but it does not work with safari.
I am wondering if you can suggest something that works cross-browsers and can manage a responsive view as well.
Thanks.
The navigator.mediaDevices.getUserMedia method should work with the latest version of safari 11. You'll want to use the MediaDevices.getUserMedia() method which has full support by almost every latest browser (except IE).
Note that if your writing an HTML file and opening it in the browser, it may not work because your browser may require a secure context (HTTPS instead of HTTP) to use that method.
See https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/getUserMedia
Also, Sam Dutton created a great example, and you can find the github code for it as well.

Make that the website becomes chrome's default start up page when a particular button is clicked [duplicate]

This question already has answers here:
How can I set default homepage in FF and Chrome via javascript?
(7 answers)
Closed 4 years ago.
I made a page redirection website for school and I was wondering if there is a way to avoid going in chrome settings and manualy setting up default browser start up page for each computer in the class.
Is there a way to access these chrome settings with JS or any other language?
Because of security restrictions, this can't be done. If such JavaScript existed, a malicious website could easily change your homepage without even asking or requiring you to click a button to do so.
Since you're in a classroom environment, I assume all the computers are managed on a network using some sort of Group Policy. You can use a Group Policy to set settings on computers on a managed network.
Here is how you could do it specifically for Chrome.
https://support.google.com/chrome/a/answer/187202?hl=en
Note In the olden days of Internet Explorer, circa version 5, you could do this with JavaScript, but IE has never been known to be the best when it comes to adhering to good security protocols.

How can website distinguish if you enter the website through Web browser or App? [duplicate]

This question already has answers here:
mobile browser device detection in .NET [closed]
(3 answers)
Closed 6 years ago.
How can website distinguish if you enter the website through Web browser such as Safari and Chrome, or through web View on mobile Application?
I am making web app. but I would like to provide different UI between when you access website with web browser or with mobile application using Web View.
There are two possible approaches:
Browsers as well as "web views" - which are kind-of headless browsers - pass a User-Agent String to your website which should be available in your Server/Programming-Environment. You may analyse those strings and provide a different UI based on that. Search Google for "webview user agent string".
Don't care about the device itself. Provide a different UI based on "features" like screen-size (using CSS Media Queries) and input-method (start your journey exploring Pointer-Events).
Nowadays most Developers will recommend option 2.
I assume, that you implement mobile application and website yourself and need to detect your own application vs. browser. I've been practicing a different solution for this.
When application runs in the mobile, you can insert a javascript bridge object into the browser's context. When application runs in browser, you check if the javascript bridge object is present and, if not, you emulate it.
All you need it to have a method for both cases something like:
nativeBridge.getClientId();
where for web you will implement it like:
if( !window.nativeBridge ){
window.nativeBridge = {
getClientId:function(){ return "web"; }
}
}
for web view you will have to add a method to the bridge that returns a different constant.
NOTE: 'nativeBridge' is just a name. you may have a different object name.

Does Javascript features change by browser? [duplicate]

This question already has an answer here:
Why Javascript upload chunk sizes change by browser?
(1 answer)
Closed 8 years ago.
I wonder something about Javascript. Does Javascript features or behaviors change by browsers?
While I was working Javascript XMLHttpRequest upload method, I noticed that Internet Explorer sending small bytes but Firefox and Google chrome sending big bytes. So while I was sending big data with Firefox or Chrome, server is giving OutOfMemory exception.
I am editing post with image details.
No Javascript features doesn't change from browser to browser, it depends upon their Javascript rendering machine (interpreter is the difference).
For example:
Google - v8 engine
Safari - JavaScriptCore
yes there is some differences (a hanful actually)
here are some examples
1- accessing the float proparity
because float is a reserved keyword you can access it in ie with:
document.getElementById("id").style.styleFloat = "left";
while in fire fox it will be :
document.getElementById("id").style.cssFloat = "left";
2-to access a class attribute you can do the following in ie :
document.getElementById("id").getAttribute("className");
while in fire fox :
document.getElementById("id").getAttribute("class");
these are the things that i had an experience with . but mostly every one is using jquery now so no need to worry about those . but here are some articles about them
http://www.impressivewebs.com/7-javascript-differences-between-firefox-ie/
http://www.willowdesign.info/blog/tag/javascript-browser-differences/
JS cross browser inconsistencies/differences
http://technologypost.blogspot.com/2008/07/ie-vs-firefox-javascript-differences_05.html

How to get a name of browser by using JavaScript? [duplicate]

This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Reliable browser detection with javascript?
How to get a name of browser by using JavaScript?
I expected to see only the name like this Firefox, Chrome, Safari etc.
If you're sure you need it: jQuery.browser. Promise you'll only use it as a last resort.
Take a look at jQuery.browser, but read the warning, it's better to detect features. What are you trying to achieve?
There is no way to confidently "get" only the name in a cross browser manner.
The best you can do is hack around with regular expressions on window.navigator.userAgent and hope future browsers don't break it.
But the userAgent is a mess. Don't touch it.
The W3C claims that
window . navigator . appName
Returns the name of the browser.
This is false as window.navigator.appName in chrome returns "NetScape"
The `Navigator object is very poorly implemented in browsers
Do not browser detect

Categories