Skip to content

Detecting design mode with JavaScript

March 8, 2007

The following was retrieved from my old SharePoint blog: http://vspug.com/kwanl/2007/03/08/detecting-design-mode-with-javascript/

There are times when you want your Javascript to have different behaviour depending on which mode the page is in. For example, in design mode, you may want to turn off some functionality or create a “preview” feature where some visual cues are provided.

Here’s a little Javascript function to detect whether or not the web part page is in design mode. The script checks the value of two hidden fields set by SharePoint.

function IsInDesignMode()
{
if(document.getElementById("MSOLayout_InDesignMode").value == '1') return true;
if(document.getElementById("MSOTlPn_SelectedWpId").value != "") return true;
return false;
}

Advertisements

From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: