Main
Content
■コンテンツ上被り固定の指示書です
挙動:サイト内のコンテンツ(動画プレーヤー等)の上にかぶるように広告が固定され、×ボタンを押すことで消えます
▼手順①:広告タグを以下のdivで囲む(レクタングルの例)
<div class="__isboostOverContent" style="display:none" data-isboost-target="#content" data-isboost
-ad-width="300" data-isboost-ad-height="250">
※ここに広告コードを記入※
</div>
※以下が設定値※
data-isboost-targetには「#配置先コンテンツのid」
data-isboost-ad-widthには広告の幅
data-isboost-ad-heightには広告の高さ
▼手順②:固定広告を設置したいページのソースの<body>内に以下のJSを設置
※挿入位置はどこでも可能ですが、極力<body>内の手前に挿入することをお勧めします
<script>
(function() {
window.addEventListener("load", function(event) {
var genCloseBtn = function() {
var elm = document.createElement('a');
elm.href = "javascript:;";
elm.classList.add('__isboostOverContentCloseBtn');
with (elm.style) {
width = "30px";
height = "14px";
background = "#f99";
border = "2px solid #fff";
borderRadius = "70px";
mozBorderRadius = "70px";
webkitBorderRadius = "70px";
color = "#fff";
padding = "6px 3px 16px";
fontSize = "14px";
display = "none";
lineHeight = "20px";
textAlign = "center";
fontWeight = "bold";
position = "absolute";
right = "-15px";
top = "-15px";
zIndex = "2147483647";
textDecoration = "none";
cursor = "hand";
}
elm.appendChild(document.createTextNode('×'));
elm.addEventListener("click", function(event) {
this.parentNode.style.display = "none";
return false;
});
return elm;
};
var boostElms = document.querySelectorAll(".__isboostOverContent");
for (var i = 0; i < boostElms.length; i++) {
var boostElm = boostElms[i];
var target = document.querySelector(boostElm.getAttribute('data-isboost-target'));
var rect = target.getBoundingClientRect();
boostElm.style.border ="4px solid #f99";
boostElm.appendChild(genCloseBtn());
}
for (var i = 0; i < boostElms.length; i++) {
var boostElm = boostElms[i];
var target = document.querySelector(boostElm.getAttribute('data-isboost-target'));
var rect = target.getBoundingClientRect();
boostElm.style.display = "inline-block";
boostElm.style.top = ((window.pageYOffset + rect.top + ((rect.height - parseInt(boostElm.getAttr
ibute('data-isboost-ad-height'))) / 2)) - 4) + "px";
boostElm.style.left = ((window.pageXOffset + rect.left + ((rect.width - parseInt(boostElm.getAttri
bute('data-isboost-ad-width'))) / 2)) - 4) + "px";
boostElm.style.zIndex = "2147483646"
boostElm.style.position = "absolute";
if (boostElm.getBoundingClientRect().width < parseInt(boostElm.getAttribute('data-isboost-ad-wi
dth'))) {
boostElm.style.display = "none";
continue;
}
boostElm.querySelector('.__isboostOverContentCloseBtn').style.display = "inline-block";
}
});
})();
</script>