I have included a js file in the content editor but it runs in the edit mode only. I have tried all the suggestions like

  1. Including text/javascript
  2. Include code between execfunc()

But it still doesn't work. Can someone please help me with this?

  • In editmode sharepoint loads many of the files like sp.js etc. What is the execfunc() you are calling? Feb 13, 2015 at 8:58
  • var ctx = new SP.ClientContext.get_current();
    – Keerthi
    Feb 13, 2015 at 14:47

1 Answer 1


Did you put the code directly inside the Content Editor? If so, try putting the code in a file in a document library and linking it to the Content Editor.

Another thing to check is if Minimal Download Strategy (MDS) is causing an issue. When the code is not working, does the URL contain "_layouts/15/start.aspx#"?

  • Thanks @Rob Windsor. I have put the code in a js file under Site Assets and included the script tags in content editor. And also the URL looks like this - "SitePages/Home.aspx"
    – Keerthi
    Feb 11, 2015 at 20:32

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.