Chrome重定向(SP模式新窗口)

时间:2017-11-21 08:47:27

标签: javascript google-chrome sharepoint

我正在使用JavaScript在默认的SharePoint 2013问题跟踪器中进行一些小型自定义。当用户提交问题(默认SharePoint功能预设)时,JavaScript应将文档重定向到新URL。在IE浏览器中,一切正常,但由于未知原因重定向在Chrome中不起作用。

我使用了location,replace.href,assign etc - 结果相同 - chrome只保存表单而不重定向。你可以给我任何暗示,为什么它不起作用?

我在线使用SP 2013(我无法访问SP设计师)

<script src="/sites/SiteAssets/Scripts/jquery.min.js" type="text/javascript"></script>  
<script type="text/javascript" src="/sites/SiteAssets/Scripts/sessvars.js"></script>
    <script language="javascript" type="text/javascript" src="/sites/_layouts/15/clientpeoplepicker.js"></script>
    <script type="text/javascript">
    // Here i have small function to get email from sharepoint peoplePicker field
    function getEmailFromPeoplePicker(title) {
        var ppDiv = $("div[title='" + title + "']")[0];
        var peoplePicker = SPClientPeoplePicker.SPClientPeoplePickerDict[ppDiv.id];
        var userList = peoplePicker.GetAllUserInfo();
        var userInfo = userList[0];
        var userEmail;
        if(userInfo != null)
        {
            userEmail = userInfo.EntityData.Email;
        }
        return userEmail;
    }


    function PreSaveAction(){
        // check if there is attachment
        if ($('#onetidIOFile').get(0).files.length === 0) {
    } else {
    OkAttach()  //attach file to form
    }

    //get email from field
    var RequestApprover = getEmailFromPeoplePicker('Assigned To');
    //create link for redirection with email at the end (ill use it latter for sending emails) 
     var targetUrl = '/sites/SitePages/RedirectDestination.aspx' + '#' + RequestAprover;
     //window.location.href = targetUrl;
    //location.replace(targetUrl);
    //window.location.assign(targetUrl);
   // window.top.location.href = targetUrl;           
   window.location.assign(targetUrl);  // <---------- redirection which works in IE and FireFox but not in Chrome
    //window.location.href = targetUrl;
     //window.location.assign(targetUrl);
     //window.parent.location.href(targetUrl);
     //setTimeout(function(){location.href = targetUrl},500);
    return true;
    }
    </script>

1 个答案:

答案 0 :(得分:0)

我相信你应该“回归假”;在PreSaveAction函数实现结束时(而不是返回true;)。在Chrome重定向中看起来比其他浏览器花费更多时间,因此Sharepoint继续通常的表单流程(例如继续使用PreSaveItem等)。