How to use Script editor web part in SharePoint 2013/2016/Online

Here we will discuss how to use script editor web part in SharePoint 2013/2016 or SharePoint Online. Script editor web part has been newly introduced in SharePoint 2013. Previously there were content editor web parts to write HTML and scripts inside a web part page in SharePoint 2013/2016/Online.

What Is Script Editor Web Part in SharePoint Online/2013/2016?

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 or SharePoint Online. We can also add HTML content into a script editor web part in SharePoint.

How to Add a Script Editor Web Part to a Web Part Page in SharePoint 2013/2016/Online

To add a script editor web part make sure you have the permission to edit the 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 know how to solve the issue, you can check Script editor and Content editor web part missing in SharePoint Online Office 365.

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

How to use Script editor web part in SharePoint 2013/2016/Online

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

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

script editor web part sharepoint online

script editor web part sharepoint online

<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 examples

SharePoint 2013 script editor web part examples

You may like following SharePoint web part tutorials:

Hope this will be helpful to know more about Script editor web part in SharePoint Online or SharePoint 2013/2016.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

  • […] have put the below JavaScript code inside a script editor web part in the SharePoint web part […]

  • […] all SharePoint groups using jsom (Javascript Object Model) which I can put the below code inside a script editor web part in a page in […]

  • […] see how to create a file using Rest API in SharePoint Online/2013/2016. You can add code inside the script editor web part in a web part page in SharePoint Online or SharePoint […]

  • […] code inside a script editor web part in a web part page and then added the below code inside the script editor web part in the web part page to […]

  • >