I want to remove the "This site: " prefix from the OOTB contextual search scope. I realise I could hack this with JavaScript, however does anyone know of a supported way to achieve this?


The only other option I could see is full customization. Deploy a feature that customize the search options so the contextual search is not displayed. Create custom search scopes, and custom search pages. You could additionally add custom search queries to "mimic' contextual search scopes. Package as a solution and deploy.

I think JavaScript will get you where you want faster. You can package the the JavaScript up as a feature so it will scale with your sites.


For those interested, here is the very simple JavaScript that will achieve this for you. You will need to place this wherever your search box appears (e.g. on your masterpage) and you will need to have a reference to the jQuery plugin.

$(document).ready(function () {
    var $scopesDropDownList = $(".ms-sbscopes > SELECT");

    if ($scopesDropDownList.length) {
        // Convert the jQuery object to a native JavaScript object.
        var scopesDropDownList = $scopesDropDownList[0];

        // Rename the contextual list and site scopes.
        for (var i = 0; i < scopesDropDownList.options.length; i++) {
            var item = scopesDropDownList.options[i];

            if (item.value == "This Site")
                item.text = item.text.substr("This Site: ".length);
            else if (item.value == "This List")
                item.text = item.text.substr("This List: ".length);

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.