开发者

Sharepoint: Going into Authoring mode when visiting a page

开发者 https://www.devze.com 2023-01-12 12:32 出处:网络
Given a the URL of a sharepoint page (eg: http://localhost/Pages/somepage.aspx), how can I visit that page and automatically go into authoring mode? I\'m hoping there\'s a way by seting a query string

Given a the URL of a sharepoint page (eg: http://localhost/Pages/somepage.aspx), how can I visit that page and automatically go into authoring mode? I'm hoping there's a way by seting a query string vari开发者_JAVA百科able (eg: http://localhost/pages/somepage.aspx?mode=authoring).

I'm okay with modifying the code-behind of the page if necessary.


I don't think you can do it based on a URL. The Edit Page menu command for both Publishing and non-publishing pages relies on a post back.

Publishing page:

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

non-publishing page:

window.location = 'javascript:MSOLayout_ChangeLayoutMode(false);';

For IE, MSOLayout_ChangeLayoutMode is in 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, '');
}


http://localhost/pages/somepage.aspx?ToolPaneView=2

0

精彩评论

暂无评论...
验证码 换一张
取 消