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

    =============other javascript resources================

    http://sharepointdevwiki.com/display/public/SharePoint+JavaScript+Functions+Overview

    http://hilfiger1014.spaces.live.com/Blog/cns!B5605D7C2A738C3D!1140.entry

  • 相关阅读:
    lua继承3
    C 调试
    lua继承
    hdoj_1102Constructing Roads(最小生成树)&& poj_2485Highways
    网络摄像头监控
    hdoj_3336Count the string(KMP)
    逻辑思维训练500题(带答案)
    AC自动机算法
    poj_3080Blue Jeans && poj_3450Corporate Identity(KMP)
    hdoj_1162Eddy's picture(最小生成树)
  • 原文地址:https://www.cnblogs.com/icedog/p/1818124.html
Copyright © 2011-2022 走看看