I am calling a function like the one below by click on divs with a certain class.
Is there a way I can check when starting the function if a user is using Internet Explorer and abort / cancel it if they are using other browsers so that it only runs for IE users ? The users here would all be on IE8 or higher versions so I would not need to cover IE7 and lower versions.
If I could tell which browser they are using that would be great but is not required.
Example function:
$('.myClass').on('click', function(event)
{
// my function
});
Best Answer
It's several years later, and the Edge browser now uses Chromium as its rendering engine.
Checking for IE 11 is still a thing, sadly.
Here is a more straightforward approach, as ancient versions of IE should be gone.
Here is my old answer (2014):
In Edge the User Agent String has changed.
Sample usage:
Default string of IE 10:
Default string of IE 11:
Default string of Edge 12:
Default string of Edge 13 (thx @DrCord):
Default string of Edge 14:
Default string of Edge 15:
Default string of Edge 16:
Default string of Edge 17:
Default string of Edge 18 (Insider preview):
Test at CodePen:
http://codepen.io/gapcode/pen/vEJNZN