-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent renderAd from overwriting the website DOM document #602
Comments
Ah, that is a problem is the creative uses |
@kasparsd |
@mkendall07 I wasn't clear about it, sorry. The core issue here is that Currently, passing the website |
Sorry to reopen, but I'm unsure of what is actually expected for the |
@brs14ku |
Try this... var adUnits = [{
code: 'mrec', //This have to be equal of an id of div in your page
mediaTypes: {
banner: {
sizes: [300,50]
}
},
bids: [{
bidder: 'bidderName like Tappx',
params: {
//the params of the bidder...
}
}]
}
//...code...
pbjs.requestBids({
timeout: 2000,
bidsBackHandler: function (bids) {
for (const bid in bids) {
//This is manual rewrite of renderAd - trick
let highestCpmBids = pbjs.getHighestCpmBids(bid);
var placement = document.getElementById(bid)
placement.write = function(adm) {this.innerHTML=adm}
placement.close = function() {console.log('closeRender')}
//This is the renderAd of Prebid
pbjs.renderAd(placement, highestCpmBids[0].adId)
}
}
}) |
By accidentally changing
document
tow
in the suggested ad creative line item, one is able to completely override the DOM of the parent document (the website) with the ad output.Would it make sense to add a
doc !== document
check here to prevent that from happening?That is even suggested in the description of the
renderAd()
method:The text was updated successfully, but these errors were encountered: