zoukankan      html  css  js  c++  java
  • SharePoint提供的一些javascript函数

    _spBodyOnLoadFunctionNames

    =============

    这是一个数组, Javascript程序员可以使用SharePoint Designer编辑SharePoint页面, 把自己定义的函数名push到这个数组中, 然后这个javascirpt函数会在页面初始化的时候被调用.

    _spBodyOnLoadFunctionNames.push("MyInitFunction");

    PreSaveItem

    =============

    如果你要在新建一个list item之前, 进行一些验证工作, 那么你需要实现一个PreSaveItem函数.

    那么这个函数我们是怎么知道的呢?

    你可以在浏览器中查看一个列表的NewForm.aspx页面的源代码, 你会发现"Finish"这个按钮的onclick事件里有这个函数的调用.

    <input type="button" 
        name="ctl00$m$g_blah_blah_blah_$diidIOSaveItem" 
        value="Finish" 
        onclick="if (!PreSaveItem())return false;
            WebForm_DoPostBackWithOptions(
                new WebForm_PostBackOptions(......))" 
        id="ctl00_m_g_blah_blah_blah_diidIOSaveItem" 
        accesskey="S" 
        class="ms-ButtonHeightWidth" 
        target="_self" 
    />

    这个PreSaveItem函数是定义在C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\1033\form.js文件中的.

    //Code below is from form.js of SharePoint OOB js file
    function PreSaveItem()
    {
          if ("function"==typeof(PreSaveAction))
          {
            return PreSaveAction();
          }
        return true;
    }

    如何使用呢? 很简单.

    //Code below is from your aspx file.
    function PreSaveItem() {
        // Do your thing here
        // .......
    }

    OptLoseFocus(opt)

    =============

    该函数来自core.js, 定义如下:

    function OptLoseFocus(opt)
    {
        var ctrl=document.getElementById(opt.ctrl);
        if (opt.selectedIndex >=0)
            SetCtrlFromOpt(ctrl, opt);
        opt.style.display="none";
    }

     

    作用是设置某个控件的选项为被选中的状态.

    ShowDropdown(textboxID)

    =============

    显示dorpdown控件, 定义在core.js和ows.js, 定义如下:

    function ShowDropdown(textboxId)
    {
        var ctrl=document.getElementById(textboxId);
        var str=ctrl.value;
        var opt=EnsureSelectElement(ctrl, ctrl.opt);
        ctrl.match=FilterChoice(opt, ctrl, "", ctrl.value);
        ctrl.focus();
    }

    资料来源:

    SharePoint JavaScript – Page Load Add function: _spBodyOnLoadFunctionNames

    http://blogs.msdn.com/b/saurabhkv/archive/2009/06/22/javascript-pageload-add-function.aspx

    Add JavaScript Date Validation into List Item forms

    http://edinkapic.blogspot.com/2007/10/add-javascript-date-validation-into.html

    Using Javascript to Manipulate a List Form Field

    http://blogs.msdn.com/b/sharepoint/archive/2007/06/21/using-javascript-to-manipulate-a-list-form-field.aspx

  • 相关阅读:
    第89题:格雷编码
    第88题:合并两个有序数组
    第86题:分隔链表
    第83题:删除排序链表中的重复元素
    第82题:删除排序链表中的重复元素II
    第81题:搜索旋转排序数组II
    redis笔记---不定时更新
    关于银行股
    开博客
    group by
  • 原文地址:https://www.cnblogs.com/awpatp/p/1745854.html
Copyright © 2011-2022 走看看