Sharepoint 2013 Javascript object model IE compatibility

梦想的初衷 提交于 2019-12-22 12:37:17

问题


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?


回答1:


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');


来源:https://stackoverflow.com/questions/23695553/sharepoint-2013-javascript-object-model-ie-compatibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!