Skip to content

Instantly share code, notes, and snippets.

@thoslin
Created January 10, 2014 10:36
Show Gist options
  • Save thoslin/8349810 to your computer and use it in GitHub Desktop.
Save thoslin/8349810 to your computer and use it in GitHub Desktop.
Asynchronously load openx
<html>
<head>
<script type="text/javascript">
var adQueue = [];
var OA_show = function(position, output) {
// queue the function call and create a place holder
adQueue.push([position, output]);
document.write("<div id='_"+position+"'></div>");
}
</script>
</head>
<body>
<div id="top_banner">
<script type='text/javascript'>
OA_show('top_banner', true);
</script>
</div>
<script type="text/javascript">
var OA_zones = {
'top_banner': 120
}
</script>
<script type='text/javascript' src='http://ads.example.com/www/delivery/spcjs.php?id=7'></script>
<script type='text/javascript'>
// queue out function calls and display ads
while(adQueue.length > 0) {
var args = adQueue.shift();
var ad = OA_show(args[0], false);
if(ad){
$("#_"+args[0]).html(ad);
}
}
</script>
</body>
</html>
<html>
<head>
<script type="text/javascript">
var OA_zones = {
'top_banner': 120
}
</script>
<!-- the script will issue a request to fetch the ads -->
<script type='text/javascript' src='http://ads.example.com/www/delivery/spcjs.php?id=7'></script>
</head>
<body>
<div id="top_banner">
<script type='text/javascript'>
// openx document.write the ad content
OA_show('top_banner', true);
</script>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment