Forum Discussion
How to add javascript to sharepoint online Modern Page
I am using old sharepoint then can add javascript function ChatLink(myMessage) to when user click then can add username to deeplink chat teams <a href="javascript:ChatLink('IT')">Chat - Microsoft Teams</a>
But when create Sharepoint Online Modern then i can not add java script. I want when user click hyperlink (as quick links....) then will open deep link chat with groupname + username .
thanhtien19 Microsoft have purposefully locked down modern SharePoint sites to prevent a lot of the customisation that was previously available in older versions. However you can create web parts with the SharePoint Framework SPFx or download samples from github at https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples where there are instructions for downloading and installing them. Also, there is a modern script editor web part available from Add an app in the SharePoint menu.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)
7 Replies
thanhtien19 I have previously achieved this using Script editor web part for modern pages developed by @Mikael Svenson using SPFx.
Check my answers on this thread for more information and how to use the web part:
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- Rob_ElliottBronze Contributor
ganeshsanap yes that was the one I was referring to above, it's pretty good.
- Rob_ElliottBronze Contributor
thanhtien19 Microsoft have purposefully locked down modern SharePoint sites to prevent a lot of the customisation that was previously available in older versions. However you can create web parts with the SharePoint Framework SPFx or download samples from github at https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples where there are instructions for downloading and installing them. Also, there is a modern script editor web part available from Add an app in the SharePoint menu.
Rob
Los Gallardos
Microsoft Power Automate Community Super User.
Principal Consultant, SharePoint and Power Platform WSP Global (and classic 1967 Morris Traveller driver)- thanhtien19Iron Contributor
Rob_Elliott : But from sample https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples how to convert to file extension .sppkg . because update to sharepoint online app catalog
You will first have to setup the SPFx development environment as given here (with the versions used in SPFx sample - can be found in package.json file): Set up your SharePoint Framework development environment
This will also come handy while setting up the SPFx environment: SharePoint Framework development tools and libraries compatibility
Then check the detailed steps given here to generate the .sppkg file (
) : Script editor web part for modern pages - Minimal Path to Awesome
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
- thanhtien19Iron ContributorHow to build webpart to only site that not all ?
Are you trying to use the SPFx web part solution for only one "site"?
If yes, you can use the site collection app catalog instead of tenant app catalog.
Check this Microsoft official documentation to enable and use site collection app catalog in SharePoint: Use the SharePoint site collection app catalog
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.