I need to add a custom JavaScript link to my SharePoint list, so it would only affect that list. I don't need to add it to any other forms. How could it be done?

I was thinking, if to change .aspx file, where the list sits (if it is possible), if this is a good idea, then where can I find that file?

EDIT: I need this to pin my top row (column names) to top of browser view, so I wouldn't lose them, when user scrolls to bottom of page.

  • Why do you need that? This could help to brind you an answer. – Juan Pablo Pussacq Laborde Apr 7 '16 at 12:54
  • Edited my question – Taurib Apr 7 '16 at 12:58
  • 3
    JSLink or adding a script editor on the views .aspx page are good ways for doing this – Robert Lindgren Apr 7 '16 at 13:00
  • How to I add script editor to my view in list. When I try it through designer, then it won't change anything – Taurib Apr 7 '16 at 13:07
  • 1
    if you want to change the display of the data, you surely want check CSR Client-Side Rendering, see this link for more information. – Mauricio Arias Olave Apr 7 '16 at 13:49

You might do as follows from the browser:

  • Edit the list page from top right gear/edit page
  • Add new web part/Script Editor to the page
  • Add your javascript code
  • Oh yeah, thanks! Forgot to look for edit page from there at all.. – Taurib Apr 7 '16 at 13:12

I usually use either a script editor web part or a content editor web part.

If you want to create sticky headers in a SharePoint list, I've been using the below library and have been pretty happy with the results.


All you have to do to implement is throw a copy of the sticky headers js file and a copy of jQuery in a script editor above the list view and you'll magically have a fixed header when you scroll the list view.

  • Thanks for the answer, I was looking at the same solution! :) – Taurib Apr 7 '16 at 13:15

The "CEWP" approach is Ok. But you need to remember that EVERY LIST VIEW creates a "new" .aspx page.

So, "AllItems.aspx", will receive a CEWP with you JS. Your list have a "MyItens.aspx" view? Another CEWP.

Be aware of this point and good luck!


1) Edit the page of the view

2) Add a Content Editor Web Part

3) Link this CEWP to a file containing JavaScript and CSS

4) Store this file in a SharePoint Document Library

Sample: https://ybbest.wordpress.com/2013/01/15/how-to-use-html-and-javascript-in-content-editor-web-part-in-sharepoint2010/

  • Thanks for the answer, forgot about edit page under gear symbol – Taurib Apr 7 '16 at 13:14
  • 1
    Steps 3 and 4 are very importante to separate the code and easy editing. – Juan Pablo Pussacq Laborde Apr 7 '16 at 13:15

Given the response William — use C# job to programmaticaly get all list views and add CEWP for each. CEWP must reference your javascript file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.