给定一个sharepoint页面的URL(例如:http://localhost/Pages/somepage.aspx),如何访问该页面并自动进入创作模式?我希望有一种方法可以设置一个查询字符串变量(例如:http://localhost/pages/somepage.aspx?mode=authoring)。
如果有必要,我可以修改页面的代码隐藏。
答案 0 :(得分:1)
我认为你不能基于URL来做到这一点。发布页面和非发布页面的“编辑页面”菜单命令依赖于回发。
发布页面:
if (document.forms['aspnetForm']['MSOLayout_InDesignMode'] != null) document.forms['aspnetForm']['MSOLayout_InDesignMode'].value = 1;
if (document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'] != null) document.forms['aspnetForm']['MSOAuthoringConsole_FormContext'].value = 1;
if (document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'] != null) document.forms['aspnetForm']['MSOSPWebPartManager_DisplayModeName'].value = 'Design';
__doPostBack('ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaEditPage_CmsActionControl','switchToAuthoring')
非发布页面:
window.location = 'javascript:MSOLayout_ChangeLayoutMode(false);';
对于IE,MSOLayout_ChangeLayoutMode位于ie55up.js:
function MSOLayout_ChangeLayoutMode(bPersonalView, bExitDesignMode)
{
if(bPersonalView !=null)
{
MSOLayout_SaveChanges();
var url=document.forms[MSOWebPartPageFormName].action;
url=RemoveQueryParameterFromUrl(url, "[p|P][a|A][g|G][e|E][v|V][i|I][e|E][w|W]");
url=RemoveQueryParameterFromUrl(url, "[tT][oO][[oO][lL][pP][aA][nN][eE][vV][iE][eE][wW]");
url=RemoveQueryParameterFromUrl(url, "[dD][iI][sS][pP][lL][aA][yY][mM][oO][dD][eE]");
if (url.indexOf("?") < 0)
url+="?";
else
url+="&";
if(bPersonalView==true)
{
document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=1;
document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Design';
url+="PageView=Personal";
document.forms[MSOWebPartPageFormName].action=url;
}
else
{
document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=1;
document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Design';
url+="PageView=Shared";
document.forms[MSOWebPartPageFormName].action=url;
}
} else if (bExitDesignMode !=null && bExitDesignMode)
{
var url=document.forms[MSOWebPartPageFormName].action;
url=RemoveQueryParameterFromUrl(url, "[tT][oO][[oO][lL][pP][aA][nN][eE][vV][iE][eE][wW]");
url=RemoveQueryParameterFromUrl(url, "[dD][iI][sS][pP][lL][aA][yY][mM][oO][dD][eE]");
document.forms[MSOWebPartPageFormName].MSOWebPartPage_Shared.value="";
document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value=0;
document.forms[MSOWebPartPageFormName].MSOSPWebPartManager_DisplayModeName.value='Browse';
document.forms[MSOWebPartPageFormName].action=url;
}
__doPostBack(MSOWebPartPageFormName, '');
}
答案 1 :(得分:0)
http://localhost/pages/somepage.aspx?ToolPaneView=2