Home > Technical & Creative Skills > Programming, Servers & Scripts

Microsoft Edge Browser Detection (5)


08-14-2015 02:27 PM #1 pain2k (Veteran Member)
Microsoft Edge Browser Detection

Hey guys,

I use browser detection on one of the lps I use in some campaigns, however an interesting issue came up recently. I realized that MS Edge also includes Chrome, Safari etc in the useragent string. I was thinking about php for the coding and not javascript. One thing that's unique to Edge is that useragent has "Edge/{version_number}" in it.

Any coders can suggest the best way to detect this separately from Chrome and or Safari?


08-14-2015 03:47 PM #2 crysper (Member)

Just check for the 'Edge' string before checking the other browsers something like

if (navigator.userAgent.indexOf('Edge')>-1) { ...}


08-14-2015 04:11 PM #3 pain2k (Veteran Member)

Is there a non-javascript solution mate?


08-14-2015 04:30 PM #4 crysper (Member)

in php should be something like


if (strpos($_SERVER['HTTP_USER_AGENT'],'Edge') !== false) {
...
}

just make sure you test this before testing for the other browsers otherwise you'll get matches for Safari or Chrome.


08-14-2015 05:27 PM #5 pain2k (Veteran Member)

Cheers!! Will get it done.


Home > Technical & Creative Skills > Programming, Servers & Scripts