0

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

1
  • Are you 100% sure that useragent is from Edge? Never seen an Useragent from Edge without "EDG" Commented Jun 17, 2021 at 18:47

1 Answer 1

0

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:

mozilla/5.0 (windows nt 10.0; win64; x64) applewebkit/537.36 (khtml, like gecko) chrome/91.0.4472.101 safari/537.36 edg/91.0.864.48

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.