Search This Blog

Tuesday, October 13, 2015

STSnavigate open a new windows in SharePoint 2013

The New (or New Document) menu item uses createNewDocumentWithRedirect function in core.js file to create a new documents (including the InfoPath form).
Here are the codes in core.js for your information.

function createNewDocumentWithRedirect(strTemplate, strSaveLocation, strProgID, bXMLForm, strRedirectUrl, defaultItemOpen) {
    if (IsClientAppInstalled(strProgID) && defaultItemOpen != 1) {
        var strIndependentProgId = strProgID.replace(/(?:\.\d+)$/, '');
        createNewDocumentWithProgID(strTemplate, strSaveLocation, strIndependentProgId, bXMLForm);
    }
    else {
        STSNavigate(strRedirectUrl + "&SaveLocation=" + makeAbsUrl(escapeProperly(strSaveLocation)) + "&Source=" + GetSource() + "&DefaultItemOpen=" + defaultItemOpen);
    }
}

function STSNavigate(Url) {
    if (isPortalTemplatePage(Url))
        window.top.location = STSPageUrlValidation(Url);
    else
        window.location = STSPageUrlValidation(Url);
}

For the codes above, as SharePoint uses window.location to navigate to the new link, the link will open in current window instead of a new window.
Therefore, you could override the STSNavigate function in the AllItems.aspx to change the behavior, here is the code sample for your information.

<asp:content contentplaceholderid="PlaceHolderAdditionalPageHead" runat="server">
       <SharePoint:RssLink runat="server"/>
      
       <Script>
       function STSNavigate(Url){
              window.open(STSPageUrlValidation(Url),"_blank");
       }
       </Script>
</asp:content>


No comments:

Post a Comment