sharepoint 2019 solution添加自定义按钮

问题描述:sharepoint2019有modern模式和经典模式两种,16即以前版本只有经典模式,经典模式支持js脚本,modern下面写了js脚本调用但是起不到作用

实现功能:在document library(RegistrationId='101')下面添加一个按钮CustomButton1,按钮实现alert("hello,Oliver!')功能

1.在原有16的solution()下面element.xml的基础上修改button的响应方法,将原来commandAction中"javascript:test();"改为"="~site/_layouts/15/2019/BeforeCustomAction.aspx"


  
  
  
  
    
      
        
          

2.新创建一个BeforeCustomAction.aspx文件,在PageHead下面添加需要的脚本引用和方法调用,这样就会在点击OliverCustomButton1的时候调用js中test()方法


           
        

3.新建一个js脚本CustomAction.js,里面加上函数方法

function test(){
    alert("Hello,Oliver!");
}

4.publish该project,然后在相应网站部署上solution,并且在CA上action feature,打开相应网站就可以看到新添加的button,并且点击响应

你可能感兴趣的:(SharePoint)