in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

kwanl's blog

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;
}

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts