March 30, 2007

Testing the ability to post from Microsoft Word 2007

Ads 2.0 Implementation Documentation

Introduction

If you haven't already, please read the Ads 2.0 Solution Architecture document to get a high-level overview of what the tool is and how to use it. This document will tell you what the tool's dependencies are, how to insert it into a web page, how to control it once the page has been loaded into a browser, and how to debug errors.

Dependencies

  • EventBroadcaster: This library initializes the root wxtools object that we use as our global namespace for global libraries and sets up basic login functionality. It allows you to decorate any object with the ability to broadcast ad-hoc messages, and for other objects to add multiple listeners for these messages. The script lives at /common/scripts/EventBroadcaster.js
  • An ad server.
  • Ad Frame web page: This is the engine for actually performing the ad call. It is a simple web page that should be hosted in the same domain as the parent web page. This page uses a minimal implementation of externals. It lives at /components/AdController/ad_frame.html

How To Insert It Into a Web Page

In the <head> of the web page, insert script calls to the following two libraries in this order:

<script src="/common/scripts/EventBroadcaster.js" type="text/javascript"></script>
<script src="/components/AdController/Ads2.js" type="text/javascript"></script>

We'll need to determine the correct host name to use for these calls, but it might be image.weather.com.

Next, determine the ad positions on the page, hopefully from the adinfo.properties file for JSPs or the ad include for static pages, and then set the positions. This should also be inside the <head>, but it doesn't have to be. It's just safest to put it there so that events happen in the correct sequence.

<script type="text/javascript">
Ads2.setPositions(['Leader1','Skyscraper','Hidden1','Hidden2']);
</script>

Last, you need to place the ads on the page. This is normally where we call OAS_RICH for the ads. The adPosition method draws an iframe into the page at that exact position for that ad position. Here's how to do it:

<script>Ads2.addPosition('Leader1');</script>

Make sure you place all of the positions that were defined by setPositions above or else the library will throw an error and not make the ad call. This is intentional so that the developer will know that there is an error, and so that we don't deploy a web page that calls an ad position but then doesn't place it on the page. The addPosition calls can be made into absolutely-positioned DIVs, if you wish; they just can't be added to the page in this manner after the page has already loaded since the library uses document.write to place the iframe tags into the page.

When the page had loaded, the library will automatically make the first ad call. It waits this long in order to ensure that all of the iframes that we will use will be populated into the DOM.

Post-Page Load Ad Control

The primary call you can make after the page has been loaded is Ads2.reload() in order to refresh all of the ads on the page. Something else you could do is call Ads2.setTarget(newSpoof), which will change the spoof being used and then refresh all of the ads on the page.

Debugging Errors

The Ads2.js library collects error messages, if thrown, until the page loads. After that, it passes all of the error messages it has collected to the wxtools.logs property. You can view the contents of that property by entering "javascript:alert(wxtools.logs)" into the browser address bar and pressing [Enter]. While primitive, it should be good enough for catching any errors without being too intrusive or disruptive of the user experience.

Posted by joewxboy at March 30, 2007 09:59 AM
Comments
Post a comment









Remember personal info?