Thursday, July 19, 2012

Check if Page is in Edit mode Javascript

I have written javascript code in my SharePoint Page which hide some controls on the page depending on the criteria.

I want to execute this script only when page is published and my problem was this script was executed if the page is in edit mode.

I have found that SharePoint maintain this html input control which is rendering on the page when it is in edit mode

You can refer to this control in javascript and do your work accordingly.

var pageMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;

if (pageMode == ''){
//Page is not in edit mode

No comments:

Post a Comment