Sharepoint 2013 Javascript对象模型IE兼容性 [英] Sharepoint 2013 Javascript object model IE compatibility

查看:86
本文介绍了Sharepoint 2013 Javascript对象模型IE兼容性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将一些JS代码注入到Wiki页面中,以允许使用MathJax库呈现LaTex标记。经过一段时间的游戏,我意识到当页面未处于编辑模式时我需要运行MathJax脚本。看起来SP2013的MS JS客户端库有一种巧妙的检查方式

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
}

这适用于最近版本的Chrome,Firefox和IE10 +,但在IE9及更低版本上失败。报告的JS错误是 SP.Ribbon。是null或未定义

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

虽然我不能确定,看起来SP2013似乎支持IE9,但是看看我看到的SP维基页面源代码的标题

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" />

问题:SP2013是否支持IE9?如果没有,是否有另一种方法来检查页面状态是否处于编辑模式?

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

推荐答案

根据规划SharePoint 2013中的浏览器支持 SharePoint 2013 完全支持 IE9 浏览器。

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

错误 SP.Ribbon。由于 SP.Ribbon.js 在执行指定代码时未加载,因此可能会出现未定义

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

使用 SP.SOD。 executeOrDelayUntilScriptLoaded(func,depScriptFileName)方法,以确保在加载JavaScript库时执行用户定义的代码。

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

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

这篇关于Sharepoint 2013 Javascript对象模型IE兼容性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆