Possible Duplicate:
Safe feature-based way for detecting Google Chrome with Javascript?
Using Javascript to detect Google Chrome to switch CSS
Is there a statement that I can use with javascript, to only execute a code if the user is using a browser other than google chrome?
The browser's built-in interpreter searches for <script> tag or . js file linked with HTML file while loading a web page, and then interpretation and execution starts. Example: In this approach, we have written JavaScript code within the HTML file itself by using the <script> tag.
Google ChromeIn the "Settings" section click on the "Show advanced settings..." Under the the "Privacy" click on the "Content settings...". When the dialog window opens, look for the "JavaScript" section and select "Allow all sites to run JavaScript (recommended)". Click on the "OK" button to close it.
These days, most cross-browser JavaScript problems are seen: When poor-quality browser-sniffing code, feature-detection code, and vendor prefix usage block browsers from running code they could otherwise use just fine. When developers make use of new/nascent JavaScript features, modern Web APIs, etc.)
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if(!is_chrome)
{
//do stuff
}
Edit: Not sure how this will effect chrome mobile browser.
Second Edit: This throws a false positive in Microsoft Edge, the below code is the updated version:
var is_chrome = (typeof window.chrome === "object" && navigator.appVersion.indexOf('Edge') === -1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With