JSFiddle - React, Tailwind, and code Playground
by Vitaliy
HTML
<button id="ua">Click</button>
CSS
#ua{
display:block;
line-height:50px;
background-image:linear-gradient(0deg, #00f, #0f0);
width:100%;
border:1px solid #ccc;
border-radius:6px;
cursor:pointer;
}
JavaScript
document.getElementById("ua").onclick = function(){
var userAgent = navigator.userAgent;
if(userAgent.indexOf("OPR") + 1){
this.style.background = "green";
alert("Opera");
return false;
}
if(userAgent.indexOf("Chrome") + 1){
this.style.background = "blue";
alert("Chrome");
return false;
}
if(userAgent.indexOf("Firefox") + 1){
this.style.background = "red";
alert("Firefox");
return false;
}
}