Sat 12 May 2007
Embedding Static JavaScript Content in HTML Areas
Posted by ChiliJoe under PeopleSoft • Tips & Techniques • RecommendationJust a simple tip. When embedding static javascript code on a page, the obvious approach is to place the code as a constant value in the HTML Area control. For example, suppose the following code:
var something = "something";
function SomeThing() {
/* Something */
/* something... */
}
This may be embedded as an HTML Area constant value: ![]()
However, most of the time it would be nice to instead store the code in an HTML definition. This not only provides a better editor, but also makes it more maintainable and search-able in Application Designer. ![]()
To assign the content of the HTML definition to the HTML Area, it is possible to bind the HTML Area to a record field and populate it in PeopleCode using GetHTMLText function. However, a better approach is to use the %JavaScript meta-HTML function on the HTML Area constant value, as follows: ![]()
In addition to being quicker to implement (no PeopleCode), the %JavaScript reference also allows the code to be cache-able by the browser — for better client-side performance.