The ShortPoint Code Editor Web Part allows you to inject Javascript code into your Modern SharePoint page. This article provides detailed instructions for implementation. We offer both a Quick Walkthrough for users familiar with the free web part and a comprehensive step-by-step tutorial for those who need more details.
Quick Walkthrough
- Get custom Javascript code.
- Navigate to the SharePoint page and click Edit.
- Click Add new web part in the location where you want to insert your HTML code.
- Search for ShortPoint Code in the web parts library and select it.
- Edit the default placeholder content properties.
- Paste your Javascript code into the Javascript field.
- Make any needed adjustments to the code and web part settings.
- Republish the page.
TABLE OF CONTENTS
Prerequisites
- Ensure the ShortPoint Code Editor Web Part is installed on your SharePoint site. For installation instructions, read our article on How to Install ShortPoint Code Editor in SharePoint.
- You have the proper SharePoint permissions to edit the target Modern SharePoint page.
Start a trial
Make your Intranet Accessible to all.
Inclusion starts with ShortPoint
Step-by-Step Tutorial
You can obtain custom Javascript code from various sources to enhance your SharePoint page functionality. The following detailed steps will guide you through how to implement them on your page:
Step 1: Prepare your custom Javascript
Obtain or write the Javascript code for your desired page functionality. For this demonstration, we'll use a sample script that displays fireworks animations when users visit the page on their birthday. We'll show you how to add this code to your Modern SharePoint page.
Here are the custom codes that we will use:
- CSS Code
- JavaScript code - this code checks for the user's birthday and launches fireworks animations
- In the web parts library, search for ShortPoint Code and select it.
Placeholder content will be added to the page.
Step 4: Paste Javascript and customize settings
- Press the Edit properties icon. This will open the editing interface of the ShortPoint Code Editor Web Part.
- Copy the CSS code provided in Step 1 and replace the default content in the CSS field. (Note: This CSS step applies specifically to our example. Your implementation may not require custom CSS code.)
- Hit Save.
- Copy the JavaScript code provided in Step 1, replace the default content in the JavaScript field, and save.
- Remove the default content in the HTML field and save.
- Disable Contain CSS Styles.
- Adjust ShortPoint Code Web Part settings according to your requirements. To learn more about these features, you can check out our article on Getting Started With ShortPoint Code Editor Web Part.
Step 5: Hit Republish
Now that you have finished configuring the Code web part, Republish the page. Your users will then be able to see the JavaScript code's effects, in our example, on their birthdays.
That's it! You can now use JavaScript code to enhance your user's intranet experience and add other dynamic features.
Related articles:
- Getting Started With ShortPoint Code Editor Web Part
- How to Add Custom Code Using the ShortPoint Code Editor Web Part
- How to Add HTML Code Using ShortPoint Code Editor Web Part
- How to Add Custom CSS Using ShortPoint Code Editor Web Part