How to Implement ADsafe

There are a few general guidelines and steps for wrapping third-party code, and thus adding in the protective checks, in the ADsafe container.

Our first task is to attach the ADsafe JavaScript library file into the page. This file can either link directly to a hosted version that is available in the Github ADsafe project (adsafe.js in https://github.com/douglascrockford/ADsafe), or it can be a local copy if you prefer:

<script src="http://www.ADsafe.org/adsafe.js"></script>

Once the script include is in place, we can make requests to create a new ADsafe object, encapsulating the application code from the third-party source:

"use strict";
ADSAFE.go("APPNAME_", function(dom){
   //application code
});

Let’s explore this object in more depth to see the markup required around the go request.

Get Programming Social Applications now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.