enter image description hereI am trying to add some JavaScript/ Style inside HTML rich text editor field in SharePoint 2013, as we can add in the content editor but it strips all script tags.

I tried embedding script inside HTML rich text editor field but it is not working and it also visible as normal text in a browser.

We have an HTML rich text editor field where we add description text which can have some anchor tags, we want to add a javascript function on onclick event in the anchor tag. We don't want to add any function to Page Layout/ Master Page. Neither wants to add a link to any JavaScript files, as we have lots of pages and calling the function by id will not be a good solution. Please advise.

  • What about using the jslink property on the site column? Jul 13, 2016 at 10:40

2 Answers 2


You can use embed code in rich HTML text editor:

enter image description here

After clicking the command, you are prompted to insert your code and given a preview:

enter image description here

Alternative solution:

SharePoint creates a Script Editor webpart on the page for you. It even includes an "Edit Snippet" button, so you can go back and edit the code later.

enter image description here

OR you can use Content editor webpart and add your JS file as a source in Content Link.

You will get more info from here.

  • 1
    I tried embedding code but it is not working. JavaScript code appears as normal text in browser . When i adding <script></script> tags it stripping all these html part. Jul 13, 2016 at 7:33
  • You need to add it within html content. Just as defined in the link I've provided in the answer. You need to attach jquery library references before using it otherwise it will give you '$ undefined error'. Jul 13, 2016 at 7:41
  • You can use script editor/ content editor webpart as an alternate solution. Jul 13, 2016 at 7:41
  • Doesn't work for me as well. It seems that the solution is related to a web part, but not to a Rich text field.
    – MikhailSP
    May 31, 2017 at 12:00

You could also upload your own html file, create a content-editor-webpart and link to the html file in the text file property of the content-editor-webpart. From here you can make changes to the html file with Sharepoint Designer

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.