In this article, I will develop the idea of binding a script to an event like loading a document/page into the browser.
In the diagram above are two examples of writing out a phrase in an alert.
In the second a function from the client side API is used. This allows you to ensure that the script is executed when the page is fully loaded so all objects can be found and controlled.
This actually binds the execution of the code to the completion of the onload event.
A function is a unit of reusable code. Because it is attached to the ‘onload’ event this means that we can now access any data or objects that have been loaded into the window.
Each browser (Chrome, Internet Explorer or Firefox) have tools that allow us to examine the structure of the page and experiment with interactions with those objects.
I prefer to use Chrome and I can access the Developer Tools by pressing F12.
Below shows the Opportunity Summary screen.
I can explore the HTML that makes up the page and I can zoom to an individual element by Right clicking on a field etc and selecting ‘inspect'.
Which allows inspection of the HTML that causes the screen to draw this element.
Sage CRM puts Standard Ids round all captions and data
The example above shows the oppo_description field
This address can be used in Custom Content scripts or by On Change Scripts. We can then control the fields Style or other properties.
The links to the other articles in the series are listed below
- The syntax of the language and the different objects available.
- The objects that are available within the Browser.
- Binding a script to an event.
- Conditional behaviour and compound statements.
- Another look at Strings, regular expressions and other objects.
- Arrays, Functions, and techniques for processing objects.