0

In our SharePoint 2010 Enterprise environment I tried adding Javascript into a Content Editor Web Part on a custom List's EditForm.aspx page, and for some reason the code only runs when the form is in "Edit" mode (i.e. to move web parts around). Otherwise nothing happens.

Furthermore, this strange behavior only happens in Chrome. In IE8 and greater, the code executes just fine when opening the form, without need to "Edit Page".

Is there a way to force it to run when the form is opened in non-edit mode? I am using ExecuteOrDelayUntilScriptLoaded(myFunction,"sp.js"); to kick off the code, if that makes any difference.

  • Is it SharePoint 2013? – Burrhus Jan 22 '14 at 19:21
  • Apologies, I have edited my question with more details. It's 2010. – Alex Jan 22 '14 at 22:01
1

In case of Publishing pages it was discovered that SP.SOD.executeOrDelayUntilScriptLoaded Method does not work properly in SharePoint 2013

So, the solution is to replace:

ExecuteOrDelayUntilScriptLoaded(func,"sp.js");

with:

// Make sure the SharePoint script file 'sp.js' is loaded before your code runs.
SP.SOD.executeFunc('sp.js', 'SP.ClientContext', func);

Please follow SP.ClientContext object description for more details

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.