0

I created my first SPFx webpart. It's a very simple one to execute some javascript, similar to what the old script editor webpart would have done.

It acts on the 'share' button you would find in the top right corner of every site collection page.

Now, it works as intended on the Home.aspx. However, since the share button also appears in other places, such as a document library, I would like to have the javascript be executing here as well.

How can this be done?

I'm not sure the other SPFx development models (Field Customizers, Application, Customizers, Command Sets) would be able to achieve this.

Thanks for your help.

1 Answer 1

2

The Client-side webparts are only applicable (can be used) on Modern Site Pages and not on other assets (such as Document Libraries). As stated by you, the customization/javascript injection done to the share button on the Home.aspx. Inorder to make the same feature be available for all the assets in your site collection you need to use SPFx Extensions (Application Customizer). You can inject Javascript using Application Customizer. For starters you can refer this link (js injection using SPFx).

2
  • Thanks! So Application Customizers are the model to use, alright. Am I correct in assuming that if the Home.aspx is still a classic team site that the Application Customizer would not run there? I would still need an SPFx webpart for that to inject the JavaScript right? Commented May 7, 2018 at 11:02
  • SharePoint Extensions will only run on Modern UI UX. Yes, your assumption is correct, if your site pages are based on Classic Team Site experience, SPFx Extensions will not work and you will have to manually add the SPFx webpart in your Classic Team Site Home Page to inject JS. Commented May 7, 2018 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.