Codepedia
.info
Home
About
Demos
Tools
SVG Wave Generator
Colors
Edit This Code :
<html> <head> <title>Detect Browser in JavaScript</title> </head> <body onload="fnBrowserDetect()"> <h1></h1> <script> function fnBrowserDetect(){ let userAgent = navigator.userAgent; let browserName; if(userAgent.match(/chrome|chromium|crios/i)){ browserName = "chrome"; }else if(userAgent.match(/firefox|fxios/i)){ browserName = "firefox"; } else if(userAgent.match(/safari/i)){ browserName = "safari"; }else if(userAgent.match(/opr\//i)){ browserName = "opera"; } else if(userAgent.match(/edg/i)){ browserName = "edge"; }else{ browserName="No browser detection"; } document.querySelector("h1").innerText="You are using "+ browserName +" browser"; } </script> </body> </html>
➤ Run / View
Result :