How to automatically clear a query from Firefox's Search bar

14th February 2007

software / tips

Now this might not be the most important thing ever, but, I think it's very handy! Say you type a search string, e.g. "Threadless t shirt", in Firefox's Search bar, and hit enter. You find what you want and browse for a while, till you need to search again. Now if you're the sort of person who clicks inside the Search bar (like me), then you will have to delete whatever you put in last time before typing a different query. Now life would be a tiny tiny bit easier if that search string would get cleared automatically whenever we did a search!

I thought the answer would be easily found on the Internet, but that wasn't the case. Thankfully the MozillaZine Firefox forums were helpful and soon I found a solution: the Searchbar Autosizer! So what does this extension (addon) do? From the website:-

Does what its name says. It auto expands (resizes) the searchbar if needed, and shrinks it if you don't have anything typed in you'd probably want to read.

Now this is good, but not what we're after... so, there's a little option in the extension's Options Dialogue Box called "Empty searchbar when a query is submitted". This option does all the magic! Remember to click the Advanced button on the first screen to get to this dialogue. Now whenever you type a query and press the Enter key, the string will be deleted, leaving the Search bar fresh and ready for a new search string. But that's not all... Since I installed this extension, I've also grown fond of its main use: auto-sizing the Search bar. I usually don't have a snake trail for a query, but this does come in handy for the times when a lot has been entered. I've set mine up as the figure below, which works great. You can also try the live demo on the extension's website to see how it works.

So we've hit two birds with one stone (so to say!). We can clear the query from the Search bar once we press the Enter keyand change the size automatically depending on the size of the search string. A shortcut guru might say that a simple Ctrl+K (Command+K on mac) would nearly do the same thing, as it automatically highlights the previous search string, ready for it to be cleared. That's an alternative too I guess... but I like my way! :)

Comments

[...] How to automatically clear a query from Firefox’s Search bar [The Authentic Fake] Original post by Lifehacker [...]

Aaron Spuler's picture
Aaron Spuler 21st February 2007 #

I use a bit of JavaScript (along with the userchrome.js extension) to get the job done.

userchrome.js extension: http://forums.mozillazine.org/viewtopic.php?t=397735

Code:

/* :::: Searchbar Autoclear :::: */
(function()
{
var searchbar = BrowserSearch.getSearchBar();
if(searchbar && "handleSearchCommand" in searchbar)
{
eval("searchbar.handleSearchCommand ="+searchbar.handleSearchCommand.toString().replace(
'var textValue = textBox.value;',
'var textValue = textBox.value; setTimeout(function(){ BrowserSearch.getSearchBar().value = ""; }, 1000);'
));
}

}());

hyperreality's picture
hyperreality 21st February 2007 #

Thanks for the top Aaron!
I've found userChrome.css to be very handy, so I think using the userchrome.js extension will give just the right result! (plus other tweaks can be added)
Great tip!

monogodo's picture
monogodo 21st February 2007 #

I don't see what the big deal is. When I click anywhere in the search text box, the previously searched phrase becomes highlighted so that it is overwritten by the new item to be searched.

gerrie's picture
gerrie 21st February 2007 #

doesnt work

ans's picture
ans 22nd February 2007 #

holy christ just use ctrl+k people.

and don't install another bloated extension - if you want to make the search box wider type about:config in the address bar, press enter, scroll down to "browser.urlbar.hideGoButton" and change the value to true. this eliminates the little green arrow that no one uses and widens the box.

hyperreality's picture
hyperreality 23rd February 2007 #

@ans
This article is not about making the search box wider, it's about automatically clearing its content when a search is done, so please read the title!
Also, if 30KB is considered bloated by you, you might want to try Searchbar Autosizer Lite (7KB), which you have to set using about:config (seems more like something you'd like).

midorigin's picture
midorigin 17th December 2007 #

thanks for the tip. i couldn't find an answer to this anywhere.

Anonymous's picture
Anonymous 16th December 2008 #

Yay! This has always annoyed me. Thank you very much for the tip.

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
CAPTCHA
Just making sure you're a person and not a 'bot... you know!
3 + 5 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.

Photography

Subscribe to RSS Feed My photos on Flickr

Reading

More books in my online bookshelf

Watching

Films, old or new, good or bad

Listening

More of my music taste on last.fm
  • Raymond Dessaints, Ensemble Amati: Brahms: Hungarian Dances for string orchestra
  • Bande Originale De Film: Waltz With Bashir

Show and Tell

Subscribe to RSS Feed Videos, photos, quotes and more
My tumblog contains interesting things that I find on the Internet.