JavaScript browser detection in SharePoint Online

Again, this article is concentrated on SharePoint Online, but is possible to work in SharePoint 2013 as well. So, in case you tested this, please let me know if is working or not. I assume will be a yes as I can recognize some of the feature from SharePoint 2007.

Detecting browser

As a SharePoint Developer, making use of web technologies, you might be requested to identify browser and develop separate code depending on what browser customer is using.

if ( === true) {
    // IE implementation

if (browseris.firefox === true) {
    // Firefox implementation

if ( === true) {
    // Chrome implementation

Detecting browser version

Sometimes, detecting browser is not sufficient and as a developer you need to identify browser version. And again, some properties of “browseris” object can help you (values should be compare with Boolean value).

// Chrome
var chrome7up = browseris.chrome7up;
var chrome8up = browseris.chrome8up;
var chrome9up = browseris.chrome9up;

// Firefox
var firefox3up = browseris.firefox3up;
var firefox36up = browseris.firefox36up;
var firefox4up = browseris.firefox4up;

// IE
var ie7down = browseris.ie7down;
var ie8down = browseris.ie8down;
var ie9down = browseris.ie9down;
var ie7up = browseris.ie7up;

I have to admit IE logic is a little bit strange, but you can still get full Internet Explorer version using this code:

var ieversion  = browseris.verIEFull;

Unfortunately, it is returning undefined in IE11 with document mode set to edge, because code is actually do not identified browser as being Internet Explorer.

// For IE11, this is false === false;

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s