jcaddy
jcaddy

Reputation: 501

Sharepoint 2013 Javascript object model IE compatibility

I am trying to inject some JS code into a wiki page to allow LaTex markup to be rendered using the MathJax library. After a bit of playing around I realised that I needed to run the MathJax script when the page was NOT in edit mode. It would appear that the MS JS client library for SP2013 has a neat way of checking

var InEditMode = SP.Ribbon.PageState.Handlers.isInEditMode();

if(!InEditMode){

 // load MathJax library from CDN
}

This works great for recent versions of Chrome, Firefox and IE10+, but fails on IE9 and below. The reported JS error is that SP.Ribbon. is null or undefined

Although I cannot be sure, it would appear that SP2013 supports IE9, but looking at the header of the SP wiki page source I see

<meta http-equiv="X-UA-Compatible" content="IE=10" />

Question: Does SP2013 support IE9? If not, is there an alternative way to check whether the page state is in Edit mode?

Upvotes: 2

Views: 2012

Answers (1)

Vadim Gremyachev
Vadim Gremyachev

Reputation: 59338

According to Plan browser support in SharePoint 2013 SharePoint 2013 completely supports IE9 browser.

The error SP.Ribbon. is null or undefined probably occurs since SP.Ribbon.js is not loaded when the specified code is executed.

Use SP.SOD.executeOrDelayUntilScriptLoaded(func, depScriptFileName) Method to make sure that the user defined code is executed when the JavaScript library is loaded.

Example

ExecuteOrDelayUntilScriptLoaded(function(){
    var InEditMode = SP.Ribbon.PageState.Handlers.isInEditMode();
    if(!InEditMode){
       //...
    }
}, 'SP.Ribbon.js');

Upvotes: 2

Related Questions