Standalone Integration
Overview
Complete Example
<!DOCTYPE html>
<html>
<head>
<title>n360ortb Standalone Example</title>
<!-- n360ortb loader -->
<script>
!function(){if(!window.n360ortb){window.n360ortb={init:function(){e("init",arguments)},fetchBids:function(){e("fetchBids",arguments)},setDisplayBids:function(){},targetingKeys:function(){return[]},que:[]};var n=document.createElement("script");n.async=!0,n.src="https://lib.nexx360.io/nexx360_ortb.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(n,t)}function e(n,t){window.n360ortb.que.push([n,t])}}();
</script>
<script>
// Initialize
n360ortb.init({
currency: 'EUR'
});
// Fetch bids and render
n360ortb.fetchBids({
slots: [
{
tagId: 'your-tag-id',
divId: 'ad-container',
sizes: [[300, 250]]
}
]
}, function(bids) {
// Check if we have a bid for this slot
var bid = bids['ad-container'];
if (bid) {
renderAd('ad-container', bid);
} else {
console.log('No bid received');
// Optionally show fallback content
}
});
function renderAd(divId, bid) {
var container = document.getElementById(divId);
// Create an iframe to render the ad
var iframe = document.createElement('iframe');
iframe.width = bid.width;
iframe.height = bid.height;
iframe.frameBorder = '0';
iframe.scrolling = 'no';
iframe.marginWidth = '0';
iframe.marginHeight = '0';
iframe.style.border = 'none';
container.appendChild(iframe);
// Write the ad markup to the iframe
var doc = iframe.contentWindow.document;
doc.open();
doc.write(bid.adm);
doc.close();
}
</script>
</head>
<body>
<h1>My Page</h1>
<div id="ad-container" style="width: 300px; height: 250px;">
<!-- Ad will render here -->
</div>
</body>
</html>Understanding the Bid Response
Handling Multiple Slots
Handling No Bids
Safe Rendering with Friendly Iframe
Refreshing Ads
Next Steps
Last updated
Was this helpful?