Script editor web part in SharePoint + enable script editor webpart in sharepoint online

In this SharePoint tutorial, we will discuss how to use the sharepoint script editor web part. We will see, how to use the script editor web part in sharepoint online and SharePoint 2013/2016/2019. Also, we will see, how to enable script editor webpart in sharepoint online.

Previously there were content editor web parts to write HTML and scripts inside a web part page in SharePoint 2013/2016/2019 and SharePoint Online.

Script Editor Web Part in SharePoint

Microsoft introduced a special web part known as a script editor web part in SharePoint 2013. The web part is designed to add scripts inside a web part page in SharePoint 2013/2016/2019 or SharePoint Online. We can also add HTML content into a script editor web part in SharePoint.

Add a SharePoint Script Editor Web Part

To add a script editor web part make sure you have permission to edit the SharePoint page. Sometimes if you are working on a subsite, even if you are an owner of the subsite, you will not see the web part categories while editing the page.

To add a script editor web part, edit the SharePoint web part page, then from the Ribbon click on INSERT -> Web Part -> then from the categories select Media and Content and then choose Script Editor web part as shown in the fig below:

script editor web part sharepoint online
script editor web part sharepoint online

Read SharePoint online spfx script editor web part

How to use Script editor web part in SharePoint

Once you add the script editor web part into the SharePoint web part page, you can see the EDIT SNIPPET button.

Then click on the EDIT SNIPPET and add the following JavaScript code.

sharepoint script editor web part
sharepoint script editor web part
<script type="text/javascript">
function Hello() {
alert('Hello World');
}
</script>

<input type=’button’ value=’Submit’ onclick="Hello();"/>

Now the UI will appear like below. Then when you click on the button it will display Hello World in a JavaScript alert box.

sharepoint 2013 script editor web part
sharepoint 2013 script editor web part

I have also created a complete video tutorial on the sharepoint script editor web part, do check it out.

sharepoint script editor

Enable script editor webpart in sharepoint online

Now, let us see, how to enable script editor web part in SharePoint Online Office 365. In the same way, we can enable content editor web part in SharePoint Online Office 365.

The content editor and Script editor web part were missing in SharePoint Online Office 365 sites. Here we will discuss, how we can enable custom script at Office 365 tenant level for SharePoint Online sites.

Enable script editor web part in SharePoint Online Office 365

Recently one of my teammates faced one issue in Office 365 SharePoint online site. She recently signed up for an Office 365 SharePoint Online trial. Then she created a SharePoint Online team site, but when she edited the web part page and try to add a script editor or content editor web part, she was not able to see all the web parts in the Ribbon (Insert -> Web Part -> Categories).

The script editor web part and content editor web part were missing in SharePoint Online site, See fig below:

sharepoint online script editor web part missing
sharepoint online script editor web part missing

Microsoft recently did one update, according to which the scripting capabilities are disabled by default for personal sites and self-service created sites in SharePoint Online Office 365. This behavior is intended to reduce the security risk of allowing users to insert custom scripts into SharePoint Online sites.

By default, in Office 365 SharePoint Online, custom scripts are disabled in Office 365 SharePoint Online. But we can enable custom script in Office 365 tenant level.

Login to your Office 365 Portal. Then Go to the SharePoint Admin Center.

Then go to Settings. If you can not see the Settings link then write Settings in the search box and click on Enter. In the search result click on the desired Settings link like below:

enable content editor webpart in sharepoint online
enable content editor webpart in sharepoint online

Then in the Settings page, go to the Custom Script section. By default, “Prevent users from running custom script on personal sites” and “Prevent users from running custom script on self-service created sites” will be selected.

modern script editor web part not showing sharepoint online
modern script editor web part not showing sharepoint online

Now select the radios button “Allow users to run custom script on personal sites” and “Allow users to run custom script on self-service created sites“. See fig below

content editor web part missing in sharepoint online
content editor web part missing in sharepoint online

Now click on OK. Once you save the page it may take up to 24 hours to reflect the changes.

Once it is reflected, you can edit a web part page in SharePoint Online and click on Add a web part, and you can see script editor and content editor web parts will be available in SharePoint Online Office 365.

You may like the following SharePoint web part tutorials:

I hope this will be helpful to know more about the Script editor web part in SharePoint Online or SharePoint 2013/2016. Also, also we saw how to enable content editor webpart in sharepoint online or enable script editor webpart in sharepoint online.

This will fix the below issues:

  • sharepoint script editor
  • sharepoint script editor web part
  • sharepoint 2013 script editor web part
  • script editor sharepoint
  • script editor web part sharepoint online
  • script editor web part
  • script editor sharepoint online
  • enable script editor webpart in sharepoint online
  • sharepoint online script editor web part missing
  • enable content editor webpart in sharepoint online
  • modern script editor web part not showing sharepoint online
  • content editor web part missing in sharepoint online
  • sharepoint script editor web part missing
  • sharepoint content editor web part missing
  • how to enable content editor webpart in sharepoint online
  • >