This tip is a modified product of a conversation that took place between a couple of my colleagues in the UK and US.
The need was to find a technique that would allow the easy clientside control of fields with the search screens. It had to be clientside because the technique was needed for the hosted product, sagecrm.com.
For example to you may want to alter the default behavior of the search screen for Opportunities. Perhaps the default value for "status" field should be set to "In Progress". The change implemented should mean that the first time you use the find opportunity screen you get the desired default of "In Progress". Then from that point on if the value is changed and a search takes place the default value is ignored and the new selected value (e.g. "Lost") would remain.
The code below uses the trick of looking for the Grid or List that would indicate whether that a search had or hadn't taken place. A list is only added to the screen once there is data to display as the result of the search. There are two functions used. There is a helper function that allows you to detect whether you are in a screen which has a list or grid. It relies on the fact the CSS class "GRIDHEAD" is only found in screens with a list. If the "GRIDHEAD" is found then we have a list and therefore the search must have taken place to display the result set.
To apply the code into the Opportunity Search feature, you would need to add it to the screen block, OpportunitySearchBox.
var allCells = document.getElementsByTagName("TD");
var boolGridPresent = false;
boolGridPresent = true;