一:_spBodyOnLoadFunctionNames('functionname')
这个函数的主要作用就是加载指定的JS函数,函数名通过字符串传入。
比如,在某个列表的dispform页面,有2个关闭按钮,如果我们希望点击它们不是进行关闭,而是弹出‘不能关闭’的提示,而该更改不能影响到其它list的话,就可以通过这个函数来实现了。方法如下:
在dispform中加入一个内容编辑部件(如果不能编辑此页面,可以在地址栏查询参数加入 &displaymode=design)
然后输入JS脚本如下:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
4
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
6
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
8
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
10
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
11
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
12
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
14
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
15
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
16
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
17
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
18
![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
其它的可参见:C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\2052下的init.js
二 Custom_AddDocLibMenuItems(m, ctx) | Custom_AddListMenuItems(m, ctx)
这2个函数是用于向文档库或列表添加自己的下拉菜单。
原型:
if (typeof(Custom_AddDocLibMenuItems) !="undefined")
{
if (Custom_AddDocLibMenuItems(m, ctx))
return;
}
从中可以看出,如果Custom_AddDocLibMenuItems返回true的话,那么页面上呈现的菜单将完全是自定义的。
如果返回false的话,除了添加您自定义的菜单外,还将呈现SP自己的菜单。
它的参数一 m 表示的是当前的菜单对象,而ctx返回的应该是当前上下文对象吧?
例:
<script language="javascript">
function Custom_AddDocLibMenuItems(m, ctx)
{
var strDisplayText = "Hi!";
var strAction ="javascript:alert('Hello!')";
var strImagePath = "";
CAMOpt(m, strDisplayText, strAction, strImagePath);
CAMSep(m);
return true;
}
</script>
---特别有意思的是,通过这个函数,您添加的菜单还可以是多级的~~~
添加具有子菜单的菜单的函数好像是 CASubM。
具体的函数,可以参见:
C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS\2052下的core.js