Using OOTB JavaScript Functions to Modify SharePoint Pages

I'll show you how to use SharePoint's OOTB JavaScript functions to easily switch pages to edit mode or display the Web Part tool pane.

Want to download the resources associated with this article? Jump to the end 👇

A while back in the WSS v2 days, Todd Bleeker blogged how you can use some of the OOTB JavaScript functions to switch a page into edit mode or show the Web Part tool pane. When would you need this? Well, were you aware that the new/edit/display forms are just Web Part Pages? You can usually add Web Parts to those pages as they typically already contain Web Part zones!

I’ve become so reliant on that post that I have to keep going back to it… even have it copied into a OneNote file. Anyway, last week at a client site someone asked a question where this was needed so I finally got fed up with the “hunt-&-peck” and made it much easier to use.

I give you the SPClientUtilities Feature. This feature only does two things:

  1. Add a new menu item to the Site Actions menu that lets you toggle into edit mode on any page (_except application pages… those within /layouts… those pages can’t be customized so the menu items if clicked on that page will throw a JS error).
  2. Add a new menu item to the Site Actions menu that lets you turn on the Web Part tool pane on any page (same limitation as above with application pages).

Only users with rights to customize the page will see the menu items. Here’s what it looks like once activated:

Site Actions

Site Actions

Ever need to add a Web Part to the new form on a Tasks list? Now you can (very easily):

Tasks

Tasks

Again, full credit for figuring this solution out goes to Todd Bleeker’s post. All I did was Feature-ize it!

Download article resources

Want the resources for this article? Enter your email and we'll send you the download link.
Andrew Connell
Developer & Chief Course Artisan, Voitanos LLC. | Microsoft MVP
Written by Andrew Connell

Andrew Connell is a full stack developer who focuses on Microsoft Azure & Microsoft 365. He’s a 20+ year recipient of Microsoft’s MVP award and has helped thousands of developers through the various courses he’s authored & taught. Andrew’s mission is to help web developers become experts in the Microsoft 365 ecosystem, so they can become irreplaceable in their organization.

Share & Comment