Thứ Năm, 10 tháng 10, 2013

Đôi khi đối với một website việc tạo ra một popup để quảng cáo cũng rất cần . Một số trang web có phần code Popup rất chuyên nghiệp là mở tab mới chứ không như các popup truyền thống là bật ra màn hình sẽ rất khó chịu . Đối với popup thì cũng có rất nhiều loại , dưới đây xin chia sẻ mọi người 3 loại code popup mà mình sưu tầm cho mọi người tham khảo

1. Popup hiện ra một cửa sổ mới không phải la tab
    Với code popoup này . Nó sẽ hiện ra một cửa sổ nhỏ bên góc phải của màn hình , sẽ không gây phiền cho người truy cập . Popup chỉ xuất hiện với lần kích đầu tiên

Vào blog thêm tiện ích HTML/javascript nhớ thêm vào Footer

<script>function addEvent(obj,eventName,func){if(obj.attachEvent){obj.attachEvent("on"+eventName,func);}else if(obj.addEventListener){obj.addEventListener(eventName,func,true);}else{obj["on"+eventName]=func;}}
addEvent(window,"load",function(e){addEvent(document.body,"click",function(e){var pX;pX=screen.width;if(!pX){pX=document.documentElement.clientWidth?document.documentElement.clientWidth:document.body.clientWidth;}
if(pX>800){if(document.cookie.indexOf("pnpopup=popactive")==-1){document.cookie='pnpopup=popactive';params='width=80';params+=', height=80';params+=', top=1650, left=1460, resizable=no, scrollbars=yes, location=yes';var w=window.open("http://chiase24gio.com/",'window1',params).blur();window.focus();}}});});</script>

2. Xuất hiện nhiều tab mỗi khi click chuột
Tìm thẻ <body> và thay nó thành

<body onclick='open_popup()'>

<script type='text/javascript'>
/* <![CDATA[ */
function open_popup() {
window.open("http://chiase24gio.com/")
window.open("http://chiase24gio.com/")
window.open("http://chiase24gio.com/")
}
/* ]]> */
</script>

3. Xuất hiện popup khi click chuột lần đầu tiên
Cách thêm nó vào blog cũng tương tự như trên

<body onclick="vtlai_popup();">

<script language="javascript">
/* <![CDATA[ */
var sinhvienit=0;
function SVIT_ADS_GetCookie(Name){
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
 return decodeURIComponent(document.cookie.match(re)[0].split("=")[1]);
return ""
}

function SVIT_ADS_SetCookie(name, value, days){
if (typeof days!="undefined"){
 var expireDate = new Date()
 var expstring=expireDate.setDate(expireDate.getDate()+days)
 document.cookie = name+"="+decodeURIComponent(value)+"; expires="+expireDate.toGMTString()
}
else document.cookie = name+"="+decodeURIComponent(value);
}

function vtlai_popup()
{
 var cookie_popup_ads = SVIT_ADS_GetCookie('sinhvienit_popup_ads');
 if (cookie_popup_ads=='') { 
    if(sinhvienit==0)
  {
   sinhvienit=1;
   var Time_expires = 24 * 3600 * 1000;
   SVIT_ADS_SetCookie('sinhvienit_popup_ads','true',Time_expires);
   var urllist = ['http://chiase24gio.com/'];
   var url = urllist[Math.floor(Math.random() * urllist.length)];
   var params = 'width=' + '300';
   params += ', height=' + '300';
   params += ', top=0,left=0,scrollbars=yes,status=1,toolbar=1,menubar=1,resizable=1,location=1,directories=1';
   var pop_ads_open = window.open(url, 'sinhvienit_ads_pop', params);
  }
 }
}
/* ]]> */

</script>

Huy vọng mọi người sẽ tìm cho mình code thích hợp để đặt vào website của mình


Không có nhận xét nào:

:) :( :)) :(( =))