Created
June 14, 2012 03:33
-
-
Save logankoester/2927868 to your computer and use it in GitHub Desktop.
Sandboxing 3rd-party ad code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script type="text/javascript" src="//caja.appspot.com/caja.js"></script> | |
<script type="text/javascript"> | |
caja.initialize({ cajaServer: 'https://caja.appspot.com/', debug: true }); | |
// Force all network requests to use HTTPS. | |
// Prevents Insecure Content errors when the host page was loaded securely. | |
var uriPolicy = { | |
rewrite: function(uri) { return( uri.replace(/^http:/, 'https:') ); } | |
} | |
// Load the ad into a sandbox | |
caja.load(document.getElementById('ad_sandbox'), uriPolicy, function(frame) { | |
frame.code( 'https://ad.doubleclick.net/YOUR_AD_LOADER', 'text/javascript' ).run( function(f){ | |
// Use callbacks to clean up further after ad code execution | |
}); | |
}); | |
</script> | |
</head> | |
<body> | |
<div id="ad_sandbox"></div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment