Lumières d'ailleurs | Coopération
X

Recherches fréquentes

Lumières d'ailleurs

05 septembre 2011
var getClosest = function (elem, selector) { // Element.matches() polyfill if (!Element.prototype.matches) { Element.prototype.matches = Element.prototype.matchesSelector || Element.prototype.mozMatchesSelector || Element.prototype.msMatchesSelector || Element.prototype.oMatchesSelector || Element.prototype.webkitMatchesSelector || function(s) { var matches = (this.document || this.ownerDocument).querySelectorAll(s), i = matches.length; while (--i >= 0 && matches.item(i) !== this) {} return i > -1; }; } // Get the closest matching element for ( ; elem && elem !== document; elem = elem.parentNode ) { if ( elem.matches( selector ) ) return elem; } return null; }; let dsk1 = document.getElementById("dsk1"); var parentElInfo = getClosest(dsk1, '.info-box'); if (parentElInfo){ dsk1 = parentElInfo; if (parentElInfo.parentElement.nodeName == "SECTION"){ dsk1 = parentElInfo.parentElement; } } if (!isMobile){ let adv = document.createElement('div'); adv.setAttribute('id', 'div-gpt-ad-'+prefixIdAdv+'_Desktop_'+categoryIdAdv+'_Artikelebene_Position-1'); let advBox = document.createElement('div'); advBox.setAttribute('class', 'advertising-box articleInnerAdv'); advBox.prepend(adv); if (parentElInfo){ dsk1.insertAdjacentElement('afterend', advBox); }else{ dsk1.insertAdjacentElement('beforebegin', advBox); } }