From a custom page layout, for a publishing site collection, how can I tell SharePoint 2013 to display...

console.log('this should display in non-edit window');

...that loads in the <head> of the page if I am not edit mode (i.e. editing a publishing page)?

If I am in edit mode, I should not even see the above script, not even in view source mode.

Is this possible?

1 Answer 1


You can put your script inside an EditModePanel control. Setting the PageDisplayMode property determines when it shows on the page.

I use them for setting different CSS on a page layout during editing and they would be perfect in your scenario. Look at some of the OOTB page layouts for examples.

  • Thanks for the reminder on this approah! I totally forgot
    – klewis
    Sep 10, 2015 at 23:37

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.