How to automatically clear a query from Firefox’s Search bar
Please Note: I’ve moved home, read this article at its new address! Thank you!
-
1
Pingback on Feb 21st, 2007 at 8:06 pm
[…] How to automatically clear a query from Firefox’s Search bar [The Authentic Fake] Original post by Lifehacker […]
-
2
Pingback on Feb 24th, 2009 at 12:28 pm
[…] 実は、肝心のこれだけのコードの書き方がなかなかわからなかった。まず、検索ボックスの検索アクションに function を bind させる方法がわからず(上記 init で eval してるところ)、次に、検索時に検索ボックスを空にすると検索エンジンに検索文字列が渡らないという現象に悩まされた(上記 onSearch で setTimeout してるところ)。 結局、いろいろ探しているうちに、userchrome.js の上で同じ事をやってる人を、こちらのブログのコメント欄で発見し、これを頼りに上記のように書いてみたら、ようやくうまくいった感じ。この辺のプロパティ名とかがオフィシャルにまとめてあるところが見付からないんだな.. どなたかご存知でしたら教えてください。 […]
February 21, 2007 at 8:58 pm
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);’
));
}
}());
February 21, 2007 at 10:01 pm
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!
February 21, 2007 at 10:03 pm
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.
February 21, 2007 at 10:23 pm
doesnt work
February 22, 2007 at 10:16 pm
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.
February 23, 2007 at 2:14 pm
@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).
December 17, 2007 at 6:29 pm
thanks for the tip. i couldn’t find an answer to this anywhere.
February 20, 2009 at 11:12 pm
For those that don’t “get” this extension… learn about middle-click pasting in unix. CTRL-K or selecting the text in the search box results in the selection buffer being overwritten.
May 21, 2009 at 6:14 am
I use Firefox regularly on Linux and am a big fan of middle-click pasting. That is exactly why I WANT this functionality. I often highlight something in a DIFFERENT application, click back on Firefox and find my search bar already has something in it. If I highlight it to remove it, I’ve just lost the text I wanted to copy in the first place. (Not lost because I can get it back from Klipper, but still.) Personally, I have absolutely no use for clicking the magnifying glass to search as hitting enter is much easier, so I’d prefer it if clicking that cleared the bar instead (a la clear buttons in OS X). Anybody know how to remap that button’s function, maybe through JavaScript?
July 29, 2012 at 1:27 pm
Btw, the add-on “SearchLoad Options” does a perfect job!! It resets the search bar, let you define to open the search results in a new tab, can reset search engine after x seconds…
https://addons.mozilla.org/en-US/firefox/addon/searchload-options/