Skip to content

Instantly share code, notes, and snippets.

@micahwave
Created July 10, 2012 19:12
Show Gist options
  • Select an option

  • Save micahwave/3085585 to your computer and use it in GitHub Desktop.

Select an option

Save micahwave/3085585 to your computer and use it in GitHub Desktop.
iframe ad
<html>
<head>
<title>adFactory</title>
<script type="text/javascript" src="http://img.timeinc.net/shared/static/js/tii_ads.js"></script>
</head>
<style type="text/css">
body * {
margin: auto;
}
</style>
<body style="padding:0;margin:0;text-align:center;">
<script type="text/javascript">
var inDapIF = true;
// overwrite existing TII function so IFRAME can insert parent URL into SCRIPT call
var TiiAd_getAdParams = function(){
var adParams = this._formatParams();
var tileParam = ';tile=' + this.tileNumber;
var secureParam = (TiiAd_isSecure()) ? ';sec=1' : '';
var puParam = (!this.config.popups) ? ';pu=0' : '';
var ordParam = ';ord=' + (this.ord || this.randomNumber);
//var ordParam = ';ord=' + parent.TIME.Gallery.ord;
var rhost = document.referrer.split('/')[2];
var srndParam = (typeof(this.srnd) != 'undefined' && this.srnd != '' && this.srnd != null) ? ';srnd=' + this.srnd : '';
var rhostParam = (typeof(rhost) != 'undefined') ? ';rhost=' + rhost : '';
var adpath = this.sitename + '/' + this.zone.toLowerCase() + adParams + rhostParam + tileParam + puParam + secureParam + srndParam + ordParam + '?';
return adpath;
}
// more overrides, get rid of dcopt = ist
var TiiAdFactoryGetAd = function() {
var width, height, zone, ad;
if (arguments.length == 2) {
width = arguments[0];
height = arguments[1];
ad = this.createAd(width, height);
} else {
width = arguments[0];
height = arguments[1];
zone = arguments[2];
ad = this.createAd(width, height, zone);
}
// ignore dcopt, these ads arent 1st
return ad;
}
var adFactory = new TiiAdFactory(parent.adConfig, parent.adFactory.zone);
adFactory.params = parent.adFactory.params;
if(location.href.indexOf('q=')>-1){
var qs = TiiAdsParseQueryString('q'),
param = qs.split(',');
}
if( param ) {
if( param[0] == 'sidebar' ) {
var ad = adFactory.getMultiAd(new Array("336x280", "300x250"));
parent.time_resize_iframe('#sidebar-ad', ad.width, ad.height);
} else if( param[0] == 'banner' ) {
var ad = adFactory.getAd(728, 90);
parent.time_resize_iframe('#banner-ad', ad.width, ad.height);
}
ad.randomNumber = parent.TIME.Gallery.ord;
ad.ord = parent.TIME.Gallery.ord;
ad.srnd = parent.adFactory.srnd;
ad.tileNumber = param[1];
ad.setParam('dcopt', '');
ad.write();
//alert( param[0] + ad._getAdUrl() );
if( param[0] == 'banner' ) {
parent.TIME.Gallery.load_sidebar_iframe(); // makes sure they cant be out of sync
}
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment