好的,那个提琴手跟踪有很大帮助。您的 HTML 中有脚本,导致页面退出 MDS 模式。
下面的代码是罪魁祸首。它显示在您的应用程序部分的 iframe 正上方。您需要使用 SPPageContentManager.RegisterClientScriptBlock 在您的代码中注册该代码。
<script type='text/javascript'>
var spAppIFrameSenderInfo = new Array(1);
var SPAppIFramePostMsgHandler = function(e)
{
if (e.data.length > 100)
return;
var regex = RegExp(/(<\s*[Mm]essage\s+[Ss]ender[Ii]d\s*=\s*([\dAaBbCcDdEdFf]{8})(\d{1,3})\s*>[Rr]esize\s*\(\s*(\s*(\d*)\s*([^,\)\s\d]*)\s*,\s*(\d*)\s*([^,\)\s\d]*))?\s*\)\s*<\/\s*[Mm]essage\s*>)/);
var results = regex.exec(e.data);
if (results == null)
return;
var senderIndex = results[3];
if (senderIndex >= spAppIFrameSenderInfo.length)
return;
var senderId = results[2] + senderIndex;
var iframeId = unescape(spAppIFrameSenderInfo[senderIndex][1]);
var senderOrigin = unescape(spAppIFrameSenderInfo[senderIndex][2]);
if (senderId != spAppIFrameSenderInfo[senderIndex][0] || senderOrigin != e.origin)
return;
var width = results[5];
var height = results[7];
if (width == "")
{
width = '300px';
}
else
{
var widthUnit = results[6];
if (widthUnit == "")
widthUnit = 'px';
width = width + widthUnit;
}
if (height == "")
{
height = '150px';
}
else
{
var heightUnit = results[8];
if (heightUnit == "")
heightUnit = 'px';
height = height + heightUnit;
}
var widthCssText = "";
var resizeWidth = ('False' == spAppIFrameSenderInfo[senderIndex][3]);
if (resizeWidth)
{
widthCssText = 'width:' + width + ' !important;';
}
var cssText = widthCssText;
var resizeHeight = ('False' == spAppIFrameSenderInfo[senderIndex][4]);
if (resizeHeight)
{
cssText += 'height:' + height + ' !important';
}
if (cssText != "")
{
var webPartInnermostDivId = spAppIFrameSenderInfo[senderIndex][5];
if (webPartInnermostDivId != "")
{
var webPartDivId = 'WebPart' + webPartInnermostDivId;
var webPartDiv = document.getElementById(webPartDivId);
if (null != webPartDiv)
{
webPartDiv.style.cssText = cssText;
}
cssText = "";
if (resizeWidth)
{
var webPartChromeTitle = document.getElementById(webPartDivId + '_ChromeTitle');
if (null != webPartChromeTitle)
{
webPartChromeTitle.style.cssText = widthCssText;
}
cssText = 'width:100% !important;'
}
if (resizeHeight)
{
cssText += 'height:100% !important';
}
var webPartInnermostDiv = document.getElementById(webPartInnermostDivId);
if (null != webPartInnermostDiv)
{
webPartInnermostDiv.style.cssText = cssText;
}
}
var iframe = document.getElementById(iframeId);
if (null != iframe)
{
iframe.style.cssText = cssText;
}
}
}
if (typeof window.addEventListener != 'undefined')
{
window.addEventListener('message', SPAppIFramePostMsgHandler, false);
}
else if (typeof window.attachEvent != 'undefined')
{
window.attachEvent('onmessage', SPAppIFramePostMsgHandler);
}spAppIFrameSenderInfo[0] = new Array("EC5C9C4B0","g_8282237a_000e_4ab0_baf6_a4ad64ccc6ba","http:\u002f\u002fapp-bda070359d354c.apps","False","False","ctl00_ctl33_g_1581e83c_d38c_4be0_81eb_1015c2ac7a1b");
</script>