Codepedia
.info
Home
About
Demos
Tools
SVG Wave Generator
Colors
Edit This Code :
<html> <head> <title>Detect Browser in JavaScript</title> </head> <body> <h1></h1> <script> var browserName = (function (agent) { switch (true) { case agent.indexOf("edge") > -1: return "MS Edge"; case agent.indexOf("edg/") > -1: return "Edge ( chromium based)"; case agent.indexOf("opr") > -1 && !!window.opr: return "Opera"; case agent.indexOf("chrome") > -1 && !!window.chrome: return "Chrome"; case agent.indexOf("trident") > -1: return "MS IE"; case agent.indexOf("firefox") > -1: return "Mozilla Firefox"; case agent.indexOf("safari") > -1: return "Safari"; default: return "other"; } })(window.navigator.userAgent.toLowerCase()); document.querySelector("h1").innerText="You are using "+ browserName +" browser"; </script> </body> </html>
➤ Run / View
Result :