Hôm nay rảnh mình share cho các bạn popup quảng cáo giữa trang áp dụng cho mã nguồn xenforo, các bạn có thể dùng nó ra các mã nguồn khác để sử dụng vẫn ok.
Cách làm như sau:
Vào template: page_container, copy hết đoạn code sau dán vào bên trên thẻ </head>
Tại code trên các bạn cần chỉnh lại các thông số sau:
Thời gian hiển thị lại sau mỗi lần đóng close chỉnh tại đoạn:
Thay link ảnh popup tại đây:
Nếu các bạn dùng 1 hình quảng cáo thì che 1 hình lại nhé, vì code trên có 2 link tương ứng với 2 quảng cáo.
Demo:
Chúc các bạn thành công
Cách làm như sau:
Vào template: page_container, copy hết đoạn code sau dán vào bên trên thẻ </head>
Mã:
<!-- --- popup ------>
<style type="text/css">
#floating
{
z-index: 9999999;
position: absolute;
width: 600px;
height: 420px;
border: 0px !important;
}
#overPage
{
background: black;
z-index: 9999999;
position: absolute;
left: 0;
top: 0;
}
</style>
<div id="ctl00_ContentPlaceHolder1_Adv_Popup_pnAdv" style="display:none">
<div id="overPage">
</div>
<div id="floating" >
<a href="javascript:closeMe();">
<!--<div style="margin:0 auto;background:url(http://vnxf.vn/styles/BANNER8X1.png) no-repeat center 0;width:690px;height:345px"></div>-->
</a>
<p style="float: right; position: relative;top:0px; left:14px">
<a href="javascript:closeMe();"><img src="http://vnxf.vn/styles/BANNER8X1.png"/></a>
</p>
</div>
</div>
<script language="javascript" type="text/javascript">
function opennew(){
var expire=new Date();
expire=new Date(expire.getTime()+30000);
document.cookie="VFGEN-FORUM=here; expires="+expire;
window.open('http://vnxf.vn/','_blank');
}
function GetCookie(name) {
var arg=name+"=";
var alen=arg.length;
var clen=document.cookie.length;
var i=0;
while (i<clen) {
var j=i+alen;
if (document.cookie.substring(i,j)==arg)
return "here";
i=document.cookie.indexOf(" ",i)+1;
if (i==0) break;
}
return null;
}
var visit=GetCookie("VFGEN-FORUM");
if (visit==null){
$("#ctl00_ContentPlaceHolder1_Adv_Popup_pnAdv").show();
}
var lastScroll;
var delay = 30;
var speed = 50;
var img_w = 490;
var img_h = 360;
function centerIt() {
$("#overPage").css("width", $(window).width());
$("#overPage").css("height", $(document).height());
$("#floating").css("left", $(window).width() / 2 - img_w / 2);
$("#floating").css("top", $(window).height() / 2 - img_h / 2 + $(document).scrollTop());
}
$(document).ready(function() {
$("#overPage").css("opacity", 0.7);
$("#overPage,#floating").show();
centerIt();
});
$(window).scroll(function() {
setTimeout(function() { ani(); }, delay);
lastScroll = new Date().getTime();
});
$(window).resize(function() {
centerIt();
});
function ani() {
if ((new Date().getTime() - lastScroll) >= (delay - 20)) {
$("#floating").animate({ top: ($(window).height() / 2 - img_h / 2 + $(document).scrollTop()) }, speed);
}
}
function closeMe() {
$("#overPage,#floating").hide();
opennew();
}
</script>
<!-----------end popup---------------->
Tại code trên các bạn cần chỉnh lại các thông số sau:
Thời gian hiển thị lại sau mỗi lần đóng close chỉnh tại đoạn:
Mã:
expire=new Date(expire.getTime()+30000);
Thay link ảnh popup tại đây:
Mã:
http://vnxf.vn/styles/BANNER8X1.png
Nếu các bạn dùng 1 hình quảng cáo thì che 1 hình lại nhé, vì code trên có 2 link tương ứng với 2 quảng cáo.
Demo:
Nguồn: bvn.vn