zoukankan      html  css  js  c++  java
  • SharePoint

    1. MSOWebPartPageFormName 获取当前form的名称,然后可用document.forms[MSOWebPartPageFormName]来得到当前form;

    2. _spPageContextInfo ,此变量时object对象,可以使用JSON.stringify() 来展示其返回的值,含有以下信息:

    {
    "webServerRelativeUrl":"/sites/jacky",
    "webAbsoluteUrl":"http://XXX/sites/jacky",
    "siteAbsoluteUrl":"http://XXX/sites/jacky",
    "serverRequestPath":"/sites/jacky/SitePages/PermissionViewer.aspx",
    "layoutsUrl":"_layouts/15",
    "webTitle":"SharePoint 2013",
    "webTemplate":"1",
    "tenantAppVersion":"2266722204",
    "isAppWeb":false,
    "webLogoUrl":"_layouts/15/images/siteicon.png",
    "webLanguage":1033,
    "currentLanguage":1033,
    "currentUICultureName":"en-US",
    "currentCultureName":"zh-CN",
    "clientServerTimeDelta":-1657,
    "siteClientTag":"198$$15.0.4779.1000",
    "crossDomainPhotosEnabled":false,
    "webUIVersion":15,
    "webPermMasks":{
      "High":2147483647,
      "Low":4294967295
    },
    "pageListId":"{bd0a6e9b-f8b7-4bcf-9f6c-f75f0b6ac49d}",
    "pageItemId":11,
    "pagePersonalizationScope":1,
    "userId":1,
    "systemUserKey":"i:0).w|s-1-5-21-1614895754-484763869-682003330-234531",
    "alertsEnabled":true,
    "siteServerRelativeUrl":"/sites/jacky",
    "allowSilverlightPrompt":"True"
    }

    使用时可以用类似 _spPageContextInfo.webServerRelativeUrl 的方式来获取数据;(注:_spPageContextInfo.userLoginName 只在SharePoint Online上可用)

    如果要获取绝对路径,可以使用以下代码:

    var url = window.location.protocol + "//" + window.location.host + _spPageContextInfo.siteServerRelativeUrl;

    3. 得到当前site page的 page ID:
          var pageID = document.forms[MSOWebPartPageFormName].SPPageStateContext_PreviousAuthoringItemUser.value;

    4. _spBodyOnLoadFunctionNames.push(“”);是将方法放在page load中执行,但最好不要用这个方式,因为它并不稳定,有时候不会起作用,最好还是用jquery的$(document).ready();

    5. 在SharePoint中使用jQuery时,不要使用太新的版本,最好使用与Visual Studio中模板自带jQuery文件相近的版本,因为老版本的IE可能不支持最新的jQuery文件(比如在SharePoint 2010中使用jQuery 2.1.0,并用IE 10进行操作时,就不起作用,但Chrome可以)。

    6. SharePoint提供的JS函数:http://www.cnblogs.com/awpatp/archive/2010/05/27/1745854.html

    7. SharePoint 2013页面右上角的 Focus on Content 按钮实则是两个<a>标签,他们的ID, onclick事件非别是:

    ctl00_fullscreenmodeBtn:
    onclick="SetFullScreenMode(true);PreventDefaultNavigation();return false;"
    
    ctl00_exitfullscreenmodeBtn:
    onclick="SetFullScreenMode(false);PreventDefaultNavigation();return false;"

    因此,如果想实现打开页面时,即可隐藏Global导航和Quick Launch区域,只关注内容,则可使用以下代码:

    <script type="text/javascript">
    _spBodyOnLoadFunctionNames.push("setFullScreenOnLoad");
    
    function setFullScreenOnLoad(){
    SetFullScreenMode(true);
    PreventDefaultNavigation();
    }
    </script>

    8. SharePoint page load时添加操作,

      <script Language="JavaScript">
        _spBodyOnLoadFunctionNames.push("NewFunction");
        function NewFunction(){

          //add code here

        }

      </script>

    9. 在SharePoint上引用jQuery文件时要使用绝对路径,不要使用相对路径(使用相对路径时,在不同页面有可能引用不到);

    10. 在SharePoint中引用JavaScript文件,“/”就意味着当前站点的根目录,例如:http://host/sitepages/home.aspx中引用site assets中的文件,只需要src="/siteassets/jquery.js";如果站点路径是http://host/sites/test/sitepages/home.aspx中引用当前站点的javascript文件,需要写“/sites/test/siteassets/jquery.js”;

    11. SharePoint 2010中添加 status bar的方法:

    var statusId = SP.UI.Status.addStatus("Last Updated:",lastUpdatedItemsInfo);//lastUpdatedItemsInfo可以是文本,也可以是HTML代码;
    SP.UI.Status.setStatusPriColor(statusId, "cobalt");

    效果:

    12. SPModalDialog 的使用方法:

    //User Defined Function to Open Dialog Framework
    function openDialog(strPageURL)
    {
        var dialogOptions = SP.UI.$create_DialogOptions();
        dialogOptions.url = strPageURL;// URL of the Page
        //dialogOptions.width = 750; // Width of the Dialog
        //dialogOptions.height = 500; // Height of the Dialog
    
        SP.UI.ModalDialog.showModalDialog(dialogOptions); // Open the Dialog
        return false; //don't refresh page
    }

    13. SharePoint 数据库中的DateTime格式为:2015-12-08T00:00:00Z,因此使用CAML来进行日期时间查询时需要先更改为此格式(结尾的字母Z标识着这个时间是UTC时间);

    14. 

  • 相关阅读:
    mysql报错:java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.
    MD5登陆密码的生成
    15. 3Sum、16. 3Sum Closest和18. 4Sum
    11. Container With Most Water
    8. String to Integer (atoi)
    6. ZigZag Conversion
    5. Longest Palindromic Substring
    几种非线性激活函数介绍
    AI初探1
    AI初探
  • 原文地址:https://www.cnblogs.com/qijiage/p/3613242.html
Copyright © 2011-2022 走看看