ไม่ทราบว่าต้องไปวางที่ไหนหรอครับ ขอบคุณครับ
วางไว้ในหน้าที่จะให้แบนเนอร์แสดง ส่วนไหนก็ได้ครับ
ง่ายสุดก็ หลัง <body> หรือ ก่อน </body> ครับ
<script>
(function(image,link){
var img = document.createElement("img");
img.src = image;
img.onload = function() {
var imgWidth = this.naturalWidth;
var imgHeight = this.naturalHeight;
var banner = document.createElement("div");
var inner = document.createElement("div");
var aLink = document.createElement("a");
var btnX = document.createElement("button");
banner.style.cssText = "position:fixed;bottom:0;left:0;right:0;";
inner.style.cssText = "margin:0 auto;width:" imgWidth "px;height:" imgHeight "px;position:relative;";
aLink.href = link;
aLink.target = "_blank";
aLink.style.cssText = "text-decoration:none;display:block;width:100%;height:100%;";
btnX.type = "button";
btnX.innerHTML = "<b>X</b>";
btnX.style.cssText = "outline:0;border:0;border-radius:0;background:#fff;color:#f00;width:26px;height:26px;position:absolute;top:0;right:-26px;";
aLink.appendChild(img);
inner.appendChild(aLink);
inner.appendChild(btnX);
banner.appendChild(inner);
document.body.appendChild(banner);
btnX.onmouseover = function() {
this.style.background = "#f00";
this.style.color = "#fff";
}
btnX.onmouseout = function() {
this.style.background = "#fff";
this.style.color = "#f00";
}
btnX.onclick = function() {
banner.style.display = "none";
}
}
})("https://60ss.github.io/img/728x100.png","https://www.mechords.com");
</script>