O'Reilly logo

Programming Social Applications by Jonathan LeBlanc

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required