On a specific website I am unable to detect if the browser is edge (chromium) because on that website I am getting following user agent on edge browser
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Safari/537.36"
There is no "edge" or "edg" keyword to detect if it's edge is there any work around for this issue.
I need to just differentiate between these two browsers only, here is my code for detection.
public isChrome(): boolean {
return /Chrome/.test(navigator.userAgent) && /Google Inc/.test(navigator.vendor);
}
public isEdge(): boolean {
return /edg|edge/.test(navigator.userAgent.toLowerCase()) && /Google Inc/.test(navigator.vendor);
}
thanks
I think the userAgent you provided is from Chrome instead of MS Edge. The userAgent of MS Edge should have edg/version at the end. For example:
For details, you could also refer to this document:How to detect Microsoft Edge in your website. If you want to determine the browser used by the user, you can refer to this case:How to detect Microsoft Chromium Edge (chredge , edgium) in Javascript