Change default text in search box with custom HTML?

Lisa Dyer December 17, 2012

Hello,

I am using Confluence 4.3.3. I am using the Documentation Theme. When editing a page, I see "Search Confluence". I want to override that.

I inserted this custom HTML block into the "At end of BODY" section in "Administration > Look and Feel > Custom HTML" section, but it failed when trying to save.

<script type="text/javascript">
 
AJS.toInit(function ($) {
        var search = jQuery(".quick-search-query");
        search.each(function() {
            searchBox = jQuery(this);
            searchBox.data("quicksearch", {
                placeholder: "Search me",
                placeholded: true
            });
            searchBox.trigger("focus");
            searchBox.trigger("blur");
        });
});
</script>

Specifically, a browser error reported from URL "<base url>/admin/doeditcustomhtml.action" that "the connection was reset while the page was loading".

What am I missing?

Or do I need to do this with a user macro e.g. {my_searchbox_text} and call {my_searchbox_text} in the "AT end of BODY" section in the "Custom HTML" view?

PS. My problem is exactly as reported in https://answers.atlassian.com/questions/20506/change-the-default-text-in-the-search-box like but seems like I can only answer it, not ask;-)

Cheers,

- lisa

2 answers

1 accepted

0 votes
Answer accepted
dleng
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 20, 2012
Lisa Dyer December 26, 2012

Thank you, Daniel!

0 votes
Reshma Bhalekar April 9, 2015

HI

Use below code,

<script type="text/javascript">
var defaultText = "Sitede ara…";
var searchBox = document.getElementById("ctl00_ctl34_S52EF3DAB_InputKeywords");

//default text after load
searchBox.value = defaultText;

//on focus behaviour
searchBox.onfocus = function () {
if (this.value == defaultText) {//clear text field
this.value = '';
}
}
</script>

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events