How can I display a message stating that we only support Chrome, Safari, Firefox, and Edge browsers conditionally for users accessing our site from other browsers like Opera using Angular 10? Does anyone have a code snippet to help me achieve this?
I attempted the following code, but it only works for Chrome.
const userAgent = navigator.userAgent;
let browser = "unknown";
this.browserDetection = (/chrome|crios/i).test(userAgent) && !(/opr|opera|chromium|edg|ucbrowser|googlebot/i).test(userAgent) ? 'Chrome' : browser;
if(this.browserDetection === browser){
this.displayMsg = "*Supported browser is Google Chrome"
}
Thank you.