The Lat49.AdHelper class provides convenient methods for fetching and displaying ads within a web page or javascript application. The class also caches ads, making the displaying of previously fetched ads much quicker. To take advantage of the caching, the same Lat49.AdHelper object should be used every time an ad is updated. This section describes some ways of creating a Lat49.AdHelper object for use.
Some Lat49 functions have been provided that make it easier to embed ads, particularly in an HTML document. Calling Lat49.initAds() will create an internally managed Lat49.AdHelper object. The initialization function must be called before any ads are to be updated, say in the header or when the body is loaded. Subsequent calls to the Lat49 functions for updating ads will then use the internal Lat49.AdHelper object to fetch and cache ads. The Lat49.initAds() function accepts the publisher ID as a parameter, and passes it to the internally managed Lat49.AdHelper object. The ID is used to keep track of which site generated each ad serve and click-through, and can be got from the Publisher Dashboard on the Lat49 site.
Example 3-2. Initializing within HTML
<!-- Initialize the Lat49 API on loading the body.
The proper publisher ID should be used here. -->
<body onload = "Lat49.initAds('12345')"> |
A javascript application can create its own Lat49.AdHelper object for use rather than using the internally managed object. Note that, if the Lat49.initAds() function is not called, then the Lat49.fetchCSS() method should be called by the document prior to updating any ads. The following example shows the necessary steps: