日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 >

SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知.

發(fā)布時間:2025/7/25 41 豆豆
生活随笔 收集整理的這篇文章主要介紹了 SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知. 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

應(yīng)用場景: 有時候我們的站點(diǎn)需要在每個頁面實(shí)現(xiàn)滾動文字的通知,怎么在不修改Master?Page的情況下實(shí)現(xiàn)這個功能?我們可以使用Javascript 和 Custom Action 來實(shí)現(xiàn)。

  • ?創(chuàng)建一個Custom Action。主要使用到 Location = 'ScriptLink' 屬性,?該屬性可以動態(tài)的加載JavaScript?文件鏈接和代碼塊到模板頁。代碼如下:

??

<Elements xmlns="http://schemas.microsoft.com/sharepoint/"><CustomAction Location="ScriptLink" criptSrc="/_layouts/15/SP2013NotificationDemo/SiteNotification.js" Sequence="101"></CustomAction><CustomAction Location="ScriptLink" ScriptBlock="var windowOnload = window.onload || function(){}; window.onload = function(){ Notification_Demo(); };" Sequence="102"></CustomAction></Elements>


?

  • 創(chuàng)建一個JavaScript?文件,去添加一段Html代碼實(shí)現(xiàn)滾動文字。這個JavaScript文件可以放在Layouts目錄下面,也可以放在站點(diǎn)的Style Library中。在HTML中主要使用到Marquee標(biāo)簽的一些屬性。
function Notification_Demo() {var elemForm = document.getElementsByTagName("form")[0];var elemDiv = document.createElement("div");elemDiv.innerHTML = "<marquee scrollamount='4' style='color:yellow;' οnmοuseοver=this.stop() οnmοuseοut=this.start()>This is a Marquee test!!!</marquee>";elemDiv.style.cssText = "background:red;width:100%;font-size:20px;";document.body.insertBefore(elemDiv, elemForm); }
  • 代碼結(jié)構(gòu)圖如下:

??Feature Scope?設(shè)置成了Site.?如果需要把這個滾動通知應(yīng)用到一個web application下面的多個site collection中,可以把Feture scope?設(shè)置成Web Application.

?

轉(zhuǎn)載于:https://www.cnblogs.com/dexter2003/p/5909402.html

總結(jié)

以上是生活随笔為你收集整理的SharePoint 2010/SharePoint 2013 Custom Action: 基于Site Collection 滚动文字的通知.的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。