|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <style> |
| 5 | + div.adslot { |
| 6 | + border-color: red; |
| 7 | + border-style: solid; |
| 8 | + width: 300px; |
| 9 | + height: 600px; |
| 10 | + } |
| 11 | + p.description { |
| 12 | + border-style: solid; |
| 13 | + } |
| 14 | + </style> |
| 15 | + <script src="//cdn.jsdelivr.net/npm/prebid.js@latest/dist/not-for-prod/prebid.js"></script> |
| 16 | + <script> |
| 17 | + |
| 18 | + var sizes = [ |
| 19 | + [300, 250], |
| 20 | + [300, 600] |
| 21 | + ]; |
| 22 | + |
| 23 | + // use the cool "Prebid Less" feature https://docs.prebid.org/dev-docs/adunit-reference.html#stored-imp |
| 24 | + var adUnits = [ |
| 25 | + { |
| 26 | + code: 'test-div-1', |
| 27 | + mediaTypes: { |
| 28 | + banner: { |
| 29 | + sizes: sizes |
| 30 | + } |
| 31 | + }, |
| 32 | + bids: [{ |
| 33 | + module: "pbsBidAdapter", |
| 34 | + ortb2Imp: { |
| 35 | + ext: { prebid: { storedrequest: { id: 'test-imp-id' }}} |
| 36 | + } |
| 37 | + }] |
| 38 | + } |
| 39 | + ] |
| 40 | + |
| 41 | + function renderAllAdUnits() { |
| 42 | + var winners = pbjs.getHighestCpmBids(); |
| 43 | + for (var i = 0; i < winners.length; i++) { |
| 44 | + renderOne(winners[i]); |
| 45 | + } |
| 46 | + } |
| 47 | + |
| 48 | + // create an iframe in the div and write the winning ad into it |
| 49 | + function renderOne(winningBid) { |
| 50 | + if (winningBid && winningBid.adId) { |
| 51 | + var div = document.getElementById(winningBid.adUnitCode); |
| 52 | + if (div) { |
| 53 | + const iframe = document.createElement('iframe'); |
| 54 | + iframe.scrolling = 'no'; |
| 55 | + iframe.frameBorder = '0'; |
| 56 | + iframe.marginHeight = '0'; |
| 57 | + iframe.marginHeight = '0'; |
| 58 | + iframe.name = `prebid_ads_iframe_${winningBid.adUnitCode}`; |
| 59 | + iframe.title = '3rd party ad content'; |
| 60 | + iframe.sandbox.add( |
| 61 | + 'allow-forms', |
| 62 | + 'allow-popups', |
| 63 | + 'allow-popups-to-escape-sandbox', |
| 64 | + 'allow-same-origin', |
| 65 | + 'allow-scripts', |
| 66 | + 'allow-top-navigation-by-user-activation' |
| 67 | + ); |
| 68 | + iframe.setAttribute('aria-label', 'Advertisment'); |
| 69 | + iframe.style.setProperty('border', '0'); |
| 70 | + iframe.style.setProperty('margin', '0'); |
| 71 | + iframe.style.setProperty('overflow', 'hidden'); |
| 72 | + div.appendChild(iframe); |
| 73 | + const iframeDoc = iframe.contentWindow.document; |
| 74 | + pbjs.renderAd(iframeDoc, winningBid.adId); |
| 75 | + } |
| 76 | + } |
| 77 | + } |
| 78 | + |
| 79 | + </script> |
| 80 | + <script> |
| 81 | + var pbjs = pbjs || {}; |
| 82 | + pbjs.que = pbjs.que || []; |
| 83 | + |
| 84 | + pbjs.que.push(function () { |
| 85 | + pbjs.setConfig({ |
| 86 | + s2sConfig: [{ |
| 87 | + accountId: '1', |
| 88 | + adapter: "prebidServer", |
| 89 | + enabled: true, |
| 90 | + endpoint: { |
| 91 | + noP1Consent: "http://localhost:8000/openrtb2/auction", |
| 92 | + p1Consent: 'http://localhost:8000/openrtb2/auction', |
| 93 | + }, |
| 94 | + timeout: 1000, |
| 95 | + debug: true, |
| 96 | + allowUnknownBidderCodes: true |
| 97 | + }], |
| 98 | + }) |
| 99 | + |
| 100 | + pbjs.addAdUnits(adUnits); |
| 101 | + pbjs.requestBids({ |
| 102 | + bidsBackHandler: renderAllAdUnits |
| 103 | + }) |
| 104 | + }); |
| 105 | + </script> |
| 106 | + |
| 107 | +</head> |
| 108 | + |
| 109 | +<body> |
| 110 | + <h1>001_banner</h1> |
| 111 | + <p class="description"> |
| 112 | + This demo uses Prebid.js to interact with Prebid Server to fill the ad slot <strong>test-div-1</strong> |
| 113 | + The auction request to Prebid Server uses a stored request, which in turn links to a stored response.</br> |
| 114 | + Look for the <strong>/auction</strong> request in your browser's developer tool to inspect the request |
| 115 | + and response. |
| 116 | + </p> |
| 117 | + <h2>↓I am ad unit test-div-1 ↓</h2> |
| 118 | + <div id="test-div-1"> |
| 119 | + </div> |
| 120 | +</body> |
| 121 | +</html> |
0 commit comments