Skip to content

Commit

Permalink
Fix safeFrame resize issue (prebid#2947)
Browse files Browse the repository at this point in the history
* the dfp container div was not being resized, which results in content overlap

* little cleanup
  • Loading branch information
mkendall07 authored and StefanWallin committed Sep 28, 2018
1 parent 476870b commit 2e19fbe
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/secureCreatives.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,14 @@ function sendAdToCreative(adObject, remoteDomain, source) {
}

function resizeRemoteCreative({ adUnitCode, width, height }) {
const iframe = document.getElementById(
find(window.googletag.pubads().getSlots().filter(isSlotMatchingAdUnitCode(adUnitCode)), slot => slot)
.getSlotElementId()).querySelector('iframe');

iframe.width = '' + width;
iframe.height = '' + height;
// resize both container div + iframe
['div', 'iframe'].forEach(elmType => {
let elementStyle = getElementByAdUnit(elmType).style;
elementStyle.width = width;
elementStyle.height = height;
});
function getElementByAdUnit(elmType) {
return document.getElementById(find(window.googletag.pubads().getSlots().filter(isSlotMatchingAdUnitCode(adUnitCode)), slot => slot)
.getSlotElementId()).querySelector(elmType);
}
}

0 comments on commit 2e19fbe

Please sign in to comment.