I need to hide the smallsearchbox until the page loads. Is there a way to inject a java script function into the process so that once the pages loads the box becomes visible?


Actually, you neither need to go the long route of creating a replacement smallsearchbox DelegateControl, nor do you need to change the HTML body of your masterpage as mentioned in other answers.

All you need is the following CSS:

<style type="text/css">
    visibility: hidden;

which will hide the searchbox from the UI.

Now you need some JavaScript to make it visible again once the page finished loading. This could either be done with jQuery or with plain and simple script like this:

<script type="text/javascript">
if (typeof(_spBodyOnLoadFunctionNames) != "undefined")
  if (_spBodyOnLoadFunctionNames != null)

function ShowSearchbox()
    document.getElementById("SRSB").style.visibility = "visible";
  catch (e) {}

The quick & dirty way to implement the above CSS & script code is to put it inside the <head> section of your masterpage by e.g. using SharePoint Designer (shudder).

The clean and reusable way is to develop a custom SharePoint DelegateControl as a feature and staple it on the placeholder "AdditionalPageHead", like described here:


and here:

How can I enable JavaScript on every page at a site level?

The "AdditionalPageHead" approach has the added advantage that you can turn it off and on simply by flipping the feature on/off and it can be applied to any masterpage on any site.

  • This rocks dude. – user2903 Feb 15 '12 at 21:35

If you want to do it for all the pages/sites then remove the Delegatecontrol from Master Page. If this does not work, you could remove it only visually by putting a div around it with display: none as CSS property. Something like this:

<div class="display:none">
  <SharePoint:DelegateControl runat="server" ControlId="SmallSearchInputBox" Version="4"/>

When SharePoint renders the page it definitely needs some contentplaceholders although you don't use it. The best way is to make them invisible.


You need a delegate control: http://msmvps.com/blogs/sundar_narasiman/archive/2011/02/19/sharepoint-2010-delegate-control-to-replace-smallsearchinputbox.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy