SharePoint Sharpener

Obsessively Sharpening SharePoint

JavaScript Tips for SharePoint

with one comment


I’ve gatherered a few productive tips for using JavaScript within SharePoint. The below commands can be used within webparts etc. or directly in the browser’s address field while you’re on a SharePoint page, like this:

Putting javascript: in front of your script snippet will fire it right there and then.

These commands are neither terribly advanced nor applicable on all pages, but they make for a useful reference all the same. I aim to continually update this page with new content so if you have any JavaScript tips, feel free to drop them in the comments.

 

Edit an application page: MSOLayout_ToggleLayoutMode()

This enables edit mode on SharePoint’s application pages, like EditForm.aspx, DispForm.aspx etc. so you can insert web parts above or below the normal content:

 

Pop-up an alert with the User ID og the logged-in user: alert(_spUserId)

 

 

Enable the Edit toolbar: javascript:__doPostBack(‘ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaShowMenu_CmsActionControl’,’reviewPage’)

Simply enables the toolbar where you can access the page edit functions:

 

 

Hide the Edit toolbar: __doPostBack(‘ctl00$PlaceHolderTopNavBar$SiteActionsMenuMain$ctl00$wsaHideMenu_CmsActionControl’,’exitMenu’)

No prizes for guessing this one.

 

Show help: TopHelpButtonClick(‘NavBarHelpHome’)

Pops up the built-in help page. Interestingly, you can try this on Microsoft’s SharePoint Conference web site:

Advertisements

Written by Thomas Sondergaard

March 23, 2009 at 11:31 pm

Posted in Development

Tagged with , ,

One Response

Subscribe to comments with RSS.

  1. Hello Thomas,

    Let me start by saying i’m not a developer, so this may be a basic question. I would like on the edit form page to highlight certain fields in a different color to bring attention on the items users need to update. I think this can be done in Designer, but I would like to see if there is a javascript option available. Thanks for your assistance.

    Samuel

    June 9, 2010 at 9:21 pm


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: