当标题栏隐藏时,SharePoint 2013应用程序通过postMessage错误调整大小

时间:2013-05-03 18:42:12

标签: sharepoint-2013

在请求调整Web部件属性>的应用部件的大小时,我遇到了iframe postMessage通信的错误。外观> Chrome Type设置为无。

主机端的postMessage处理程序中的JavaScript错误依赖于Web部件标题:

TypeError: document.getElementById(...) is null
document.getElementById(webPartDivId + '_ChromeTitle').style.cssText = widthCssText;

我发现这里记录的没有提供解决办法:

http://yuriburger.net/2013/04/27/errors-resizing-a-sharepoint-2013-app-part-client-web-part/

我已经尝试覆盖添加到应用部分的SPAppIFramePostMsgHandler,但我认为范围不允许。或者至少我不确定为什么,但它还没有工作。

有没有人知道这方面的解决方法?

谢谢!

2 个答案:

答案 0 :(得分:0)

我会在网站上注册脚本动作 使用我修改的SPAppIFramePostMsgHandler函数,在这种情况下我将其称为mod_SPAppIFramePostMsgHandler 并添加此

setTimeout(function(){
  if(typeof SPAppIFramePostMsgHandler == "undefined")
    return;
  if (typeof window.addEventListener != 'undefined') {
    window.removeEventListener('message',SPAppIFramePostMsgHandler);
    window.addEventListener('message', mod_SPAppIFramePostMsgHandler, false);
  }
  else if (typeof window.attachEvent != 'undefined') {
    window.detachEvent('onmessage', SPAppIFramePostMsgHandler);
    window.attachEvent('onmessage', mod_SPAppIFramePostMsgHandler);
  }
}, 200);

没试过,但是如果它有帮助的话。

答案 1 :(得分:0)

事实证明,3月12日的SharePoint Server更新中解决了这个问题:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;2767999