Last active
April 12, 2017 09:07
-
-
Save Niek/657eef225e356fdb3ff25dfa2c947616 to your computer and use it in GitHub Desktop.
Prebid Atomx example
This file contains 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
<!doctype html> | |
<html> | |
<head> | |
<meta charset=utf-8> | |
<title>Prebid Atomx example</title> | |
<head> | |
<body> | |
<!-- Include prebid.js version 0.21.0 or higher --> | |
<script src="prebid.js"></script> | |
<!-- The ad slot to render the ad in --> | |
<div id="adslot"></div> | |
<script> | |
var pbjs = pbjs || {}; | |
pbjs.que = pbjs.que || []; | |
pbjs.que.push(function() { | |
var adUnits = [{ | |
code: 'adslot', | |
sizes: [300, 250], | |
bids: [{ | |
bidder: 'atomx', | |
params: { | |
id: 7395 // Replace with your placement ID of Atomx. Any placement ID is enable for prebid | |
} | |
} | |
// Add other bidders here | |
] | |
}]; | |
pbjs.addAdUnits(adUnits); | |
pbjs.requestBids({ | |
// This callback gets triggered when all bids for this | |
// ad unit come back. | |
bidsBackHandler: function(bidResponses) { | |
var container = document.getElementById('adslot'); | |
var bid = pbjs.getHighestCpmBids('adslot')[0]; | |
if (bid.ad || bid.adUrl) { | |
if (bid.ad) { | |
window.__atomx_tagn = (window.__atomx_tagn || 0) + 1; | |
var tagid = 'atomxtag' + window.__atomx_tagn; | |
container.innerHTML = '<iframe src="javascript:"<html><body></body></html>"" id=' + tagid + ' frameborder=0 marginwidth=0 marginheight=0 scrolling=no allowtransparency=true width=' + bid.width + ' height=' + bid.height + '></iframe>'; | |
var i; | |
var ifrm = document.getElementById(tagid); | |
if (ifrm.contentWindow) { | |
i = ifrm.contentWindow; | |
} else if (ifrm.contentDocument.document.document) { | |
i = ifrm.contentDocument.document; | |
} else if (ifrm.contentDocument) { | |
i = ifrm.contentDocument; | |
} | |
if (i) { | |
i.document.open(); | |
i.document.write('<head><style>html,body{padding:0;margin:0;overflow:hidden}`+style+`</style><body>' + bid.ad); | |
i.document.close(); | |
} | |
} else if (bid.adUrl) { | |
container.innerHTML = '<iframe src="' + bid.adUrl + '" frameborder=0 marginwidth=0 marginheight=0 scrolling=no allowtransparency=true width=' + bid.width + ' height=' + bid.height + '></iframe>'; | |
} | |
} | |
} | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment