应用场景: 有时候我们的站点需要在每个页面实现滚动文字的通知,怎么在不修改Master Page的情况下实现这个功能?我们可以使用Javascript 和 Custom Action 来实现。

  • 创建一个Custom Action。主要使用到 Location = 'ScriptLink' 属性, 该属性可以动态的加载JavaScript 文件链接和代码块到模板页。代码如下:
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">

  <CustomAction Location="ScriptLink"
criptSrc="/_layouts/15/SP2013NotificationDemo/SiteNotification.js"
Sequence=""></CustomAction> <CustomAction Location="ScriptLink"
ScriptBlock="var windowOnload = window.onload || function(){}; window.onload = function(){ Notification_Demo(); };"
Sequence=""></CustomAction> </Elements>
  • 创建一个JavaScript 文件,去添加一段Html代码实现滚动文字。这个JavaScript文件可以放在Layouts目录下面,也可以放在站点的Style Library中。在HTML中主要使用到Marquee标签的一些属性。
function Notification_Demo() {
var elemForm = document.getElementsByTagName("form")[];
var elemDiv = document.createElement("div");
elemDiv.innerHTML = "<marquee scrollamount='4' style='color:yellow;' onmouseover=this.stop() onmouseout=this.start()>This is a Marquee test!!!</marquee>";
elemDiv.style.cssText = "background:red;width:100%;font-size:20px;";
document.body.insertBefore(elemDiv, elemForm);
}
  • 代码结构图如下:

Feature Scope 设置成了Site. 如果需要把这个滚动通知应用到一个web application下面的多个site collection中,可以把Feture scope 设置成Web Application.

SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知.的更多相关文章

  1. SharePoint 2013 How to Backup Site Collection Automatically With a PowerShell Script

    In this post I will introduce a way how to run a script for backing up SharePoint data which could b ...

  2. [SharePoint 2010] SharePoint 2010 部署、收回和删除解决方案----STSADM和PowerShell

    STSADM stsadm -o addsolution –filename c:\bin\CustomerSiteSearch.wsp stsadm -o deploysolution –name ...

  3. SharePoint 2010、2013多个域之间互信(Domain Trust)的设计与实施

    在现实的业务场景中,有时为了更好的管理域用户和服务.我们往往会创建多个分散式的域,每个域的Administrator专注于维护特定域中的用户和资源,Administrator也可以定义安全策略,比如账 ...

  4. [SharePoint 2010] SharePoint 2010上多人同時編輯Office 2010文件

    Office 2010這個版本,提供了一個令人興奮的新功能,那就是它可以讓多人同時編輯一份Office 2010的文件. 這是一個很大的突破. 以往在與SharePoint搭配下的分享環境,檔案只能被 ...

  5. [SharePoint 2010] SharePoint 2010 FBA 配置以及自定义首页

    https://blogs.msdn.microsoft.com/kaevans/2010/07/09/sql-server-provider-for-claims-based-authenticat ...

  6. SharePoint 2010 将带有工作流的模板移动到另一个站点集

    HOWTO Move or Migrate SharePoint 2010 List-based Workflows between Sites and Site Collections I’ve e ...

  7. [SharePoint 2010] 自定义字段类型开发(二)

    在SharePoint 2010中实现View Action Button效果. http://www.sharepointblogs.be/blogs/vandest/archive/2008/06 ...

  8. sharepoint 2010 列表数据分页控件介绍 pagination UserControl

    转:http://blog.csdn.net/chenxinxian/article/details/8714391 这里主要是介绍下最近开发的一个sharepoint列表或者文档库的分页控件,并且把 ...

  9. SharePoint 2010 Form Authentication (SQL) based on existing database

    SharePoint 2010 表单认证,基于现有数据库的用户信息表 本文主要描写叙述本人配置过程中涉及到的步骤,仅作为參考,不要仅限于此步骤. 另外本文通俗易懂,适合大众口味儿. I. 开启并配置基 ...

随机推荐

  1. 如何在mac上安装composer(How to install composer on the Mac)

    Change into a directory in your path like cd /usr/local/bin Get Composer curl -sS https://getcompose ...

  2. 初识--Ajax & Json

    1,AJAX是一种进行页面局部异步刷新技术. 用AJAX向服务器发送请求和获得服务器返回的数据并更新到页面中. 不是刷新整个页面,而是在HTML页面中使用JavaScript创建XMLHTTPRequ ...

  3. Table of Contents - Tomcat

    Manager 持久化 Session JNDI Resources JNDI 配置 JDBC DataSources DBCP 配置 Realm Configuration 设置 HTTP 基本认证 ...

  4. MongoDB - The mongo Shell, Write Scripts for the mongo Shell

    You can write scripts for the mongo shell in JavaScript that manipulate data in MongoDB or perform a ...

  5. 浅谈sql 、linq、lambda 查询语句的区别

    浅谈sql .linq.lambda 查询语句的区别 LINQ的书写格式如下: from 临时变量 in 集合对象或数据库对象 where 条件表达式 [order by条件] select 临时变量 ...

  6. CSS之拖拽1

    PageX:鼠标在页面上的位置,从页面左上角开始,即是以页面为参考点,不随滑动条移动而变化. clientX:鼠标在页面上可视区域的位置,从浏览器可视区域左上角开始,即是以浏览器滑动条此刻的滑动 到的 ...

  7. ruby(html)

    有的时候,我们要给汉字标记拼音,让拼音显示要汉字的上面 <ruby>中国人<rp>(</rp><rt>zhong guo ren</rt>& ...

  8. spring3中新增的@value注解

    在spring 3.0中,可以通过使用@value,对一些如xxx.properties文件 中的文件,进行键值对的注入,例子如下: 1 首先在applicationContext.xml中加入:   ...

  9. 基类和派生类--this

    基类指针在程序运行的时候的确指向的是一个派生类的对象,但指针的类型仍然是基类指针.C++是一种强类型语言,因此不能用基类指针类型的指针直接调用派生类:而且,同一个类可能有多种不同的派生类,因此不知道实 ...

  10. 《linux 网卡别名的添加和绑定》RHEL6

    网卡别名的配置: 这个和ifconfig临时修改网卡ip 差不多,但是不一样.都是临时的,只要重启电脑就没了. 配永久的ip别名: cp ifcfg-eth0  ifcfg-eth0:0 vim if ...