Sage CRM has a Client Side method crm.ready() which is used to execute scripts once the page is loaded.
We do not have to worry whether the browser is Chrome or Internet Explorer. The crm.ready() method will take the browser version into account and add the function we pass to it in the correct way.
[code language="javascript"]
crm.ready(function(){
//function script goes here
})
[/code]
The crm.ready() will execute the scripts as soon as the page's DOM hierarchy has been fully constructed. The function passed to crm.ready() is guaranteed to be executed after the DOM is ready. It is actually tied to loading of the document object, so this is the ideal location to run other crm clientside code.
The following example script can be added to the custom content box of the CompanyBoxLong screen and will highlight in red the comp_status field when the value of the field is 'Closed'.
[code language="javascript"]
<script>
crm.ready(function(){
if (crm("comp_status").value()== "Closed")
{
crm("comp_status").highlight("red");
}
})
</script>
[/code]