Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Safe feature-based way for detecting Google Chrome with Javascript?

As the title states, I'd be interested to find a safe feature-based (that is, without using navigator.appName or navigator.appVersion) way to detect Google Chrome.

By feature-based I mean, for example:

if(window.ActiveXObject) {
    // internet explorer!
}

Edit: As it's been pointed out, the question doesn't make much sense (obviously if you want to implement a feature, you test for it, if you want to detect for a specific browser, you check the user agent), sorry, it's 5am ;) Let me me phrase it like this: Are there any javascript objects and/or features that are unique to Chrome...

like image 295
jeannicolas Avatar asked Sep 17 '08 08:09

jeannicolas


People also ask

Is it safe to enable JavaScript on Chrome?

Is it safe to enable JavaScript? JavaScript is so essential to the modern web that most browsers include a dedicated JavaScript engine just to run it. Most of the time, JavaScript is safe. Many websites use the library of prewritten JavaScript called JQuery—it's used by 73% of the 10 million most popular websites.

What is feature detection in JavaScript?

Feature detection involves working out whether a browser supports a certain block of code, and running different code depending on whether it does (or doesn't), so that the browser can always provide a working experience rather than crashing/erroring in some browsers.

Is Chrome safe for privacy?

Chrome is secure by default, protecting you from dangerous and deceptive sites that might steal your passwords or infect your computer. Advanced technologies, such as site isolation, sandboxing, and predictive phishing protections, keep you and your data safe.


1 Answers

isChrome = function() {
    return Boolean(window.chrome);
}
like image 78
pcorcoran Avatar answered Sep 18 '22 22:09

pcorcoran