Code popup xuat hien chi 1 lan khi vao trang web blogspot

Code popup xuất hiện chỉ 1 lần khi vào trang web blogspot. Hướng tạo popup thông báo,banner quảng cáo xuất hiện chỉ 1 lần khi vào trang web blogspot.

Hôm nay mình sẽ hướng dẫn các bạn tạo code tạo popup thông báo hay banner thông báo,quảng cáo...chỉ lần đầu tiên vào website không xuất hiện thêm nữa khí vào đọc các bài viết khác nhau để không gây khó chịu cho người dùng


Code popup thông báo xuất hiện chỉ 1 lần khi vào trang web blogspot

Cách thực hiện như sau:

Bước 1: Thêm đoạn code sau lên trên thẻ đóng </head>

<style >
.modal-bg {
position: fixed;
height: 100%;
width: 100%;
background: rgba(0,0,0,.8);
z-index: 999;
display: none;
top: 0;
left: 0;
}
.modal {
visibility: hidden;
text-align:center;
top: -400px; 
left: 40%;
margin-left: -250px;
width: 690px;
background: url(modal-gloss.png) no-repeat -200px -80px;
position: absolute;
z-index: 9999;
padding: 30px 40px 34px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0 0 10px rgba(0,0,0,.4);
-webkit-box-shadow: 0 0 10px rgba(0,0,0,.4);
-box-shadow: 0 0 10px rgba(0,0,0,.4);
}

.modal.small  { width: 200px; margin-left: -140px;}
.modal.medium  { width: 400px; margin-left: -240px;}
.modal.large  { width: 600px; margin-left: -340px;}
.modal.xlarge  { width: 800px; margin-left: -440px;}

.modal .close-modal {
font-size: 42px;
line-height: .5;
position: absolute;
top: 24px;
right: 33px;
color: red;
text-shadow: 0 -1px 1px rbga(0,0,0,.6);
font-weight: bold;
cursor: pointer;
}
.big-link { display:block; margin-top: 100px; text-align: center; font-size: 70px; color: #06f; }
</style>
  <!-- <script type="text/javascript" src="jquery-1.4.4.min.js"></script> -->
  <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script>
  <script type="text/javascript" src="https://seovnpro.googlecode.com/files/popup.js"></script>


<script type="text/javascript" >
    jQuery.noConflict();      /* dòng chống conflict jquery */
    jQuery(window).load(function() {
        if(document.cookie.indexOf("adf") == -1) /*  Bỏ dòng này thì nó hiện thông báo liên tục mỗi khi mở web lên rất là phiền  */
        {
            document.cookie = "popunder1=adf";
            jQuery('#myModal').bittuotblog(jQuery('#myModal').data());
        }
    });
</script>
<div id="myModal" class="modal">
   <img src="http://hyundaihillstate.com.vn/wp-content/uploads/2014/03/Untitled.png" />
   <a class="close-modal">X</a>
</div>

Chú ý:
- Các bạn thay đổi các thuộc trình trong css phủ hợp để hiển thị tốt trên web nhé
- Thay phần  <img src="link ảnh cảu bạn cần hiển thi" />   bằng hình ảnh của bạn nhé. Bạn có thể thay nó bằng đoạn text thông báo túy ý cũng dc
- Còn đối với đoạn này: <script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.js"></script> bạn có thể bỏ đi nếu nó không chạy thì có thể do bị xung đột jquery hoặc javascript.
1. Đăng nhập vào tài khoản Blogger
2. Vào phần thiết kế (Design)
3. Chọn chỉnh sửa HTML (Edit HTML)
4. Bạn tìm đến thẻ <body> và thay nó thành 1 trong 2 đoạn Script sau
A. Javascript xuất hiện nhiều tab mỗi khi click chuột
<body onclick='open_popup()'>

<script type='text/javascript'>
/* <![CDATA[ */
function open_popup() {
window.open("http://www.luubuttuoixanh.com")
window.open("http://share123vn.blogspot.com/")
window.open("http://www.share123.vn/")
}
/* ]]> */
</script>

Ở trên mình mặc định là 3 trang sẽ được mở ra khi click chuột, bạn hoàn toàn có thể thêm nhiều hơn bằng cách thêm window.open("địa chỉ web/blog").
B. Javascript xuất hiện popup khi click chuột lần đầu tiên (theo sinhvienit.net)

<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 *  * 1000;
SVIT_ADS_SetCookie('sinhvienit_popup_ads','true',Time_expires);
var urllist = ['http://share123vn.blogspot.com','http://www.luubuttuoixanh.com','http://www.share123.vn'];
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>



Đối với đoạn script này thì cửa sổ Popup chỉ mở ra khi bạn click chuột lần đầu tiên khi truy cập một blog, các thao tác click về sau cửa sổ popup sẽ khi còn xuất hiện như script đầu tiên, script đầu tiên chỉ cần bạn click là nó xuất hiện tab mới tần suất xuất hiện cao hơn script này. Hơn nữa script này sẽ lấy ngẫu nhiên trang web/blog trong urllist để xuất hiện.

C. Xuất hiện nhiều cửa sổ khi click lần đầu tiên


Ở code phần A thì mỗi lần bạn click vào vị trí bất kỳ trên blog các cửa sổ sẽ xuất hiện ngay, còn code phần B thì các cửa sổ chỉ xuất hiện lần lượt và ngẫu nhiên khi bạn click trên blog lần đầu tiên vào blog. Code phần C này là sự kết hợp 2 code trên, tức là khi bạn click vào blog lần đầu tiên tất cả các cửa sổ đều xuất hiện và chỉ 1 lần duy nhất, những cú click tiếp theo trên cùng 1 trình duyệt thì các cửa sổ không xuất hiện nữa với khoảng thời gian nhất định.
<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 params = 'width=' + '600';
params += ', height=' + '500';
params += ',scrollbars=yes,status=1,toolbar=1,menubar=1,resizable=1,location=1,directories=1';

var vtlai_popup_0 = window.open('http://www.share123.vn', 'vtlai_popup_0', params +', top=0,left=0');

var vtlai_popup_1 = window.open('http://luubuttuoixanh.com', 'vtlai_popup_1', params +', top=0,left=0');

var vtlai_popup_2 = window.open('http://share123vn.blogspot.com', 'vtlai_popup_2', params +', top=0,left=0');

var vtlai_popup_3 = window.open('http://www.phimhcm.com/', 'vtlai_popup_3', params +', top=0,left=0');

}

}
}
//]]>
</script>
D. Code tạo quảng cáo popup xuất hiện 1 lần/1 ngày/1 ip
Tìm đến thẻ <body> và thay thế thành như bên dưới

<body onclick='popunder();'>

<script>
/* <![CDATA[ */
function Set_Cookie(a,b,c,e,f,g){var d=new Date;d.setTime(d.getTime());d=new Date(d.getTime()+c);document.cookie=a+"="+escape(b)+(c?";expires="+d.toGMTString():"")+(e?";path="+e:"")+(f?";domain="+f:"")+(g?";secure":"")}function Get_Cookie(a){var b=document.cookie.indexOf(a+"="),c=b+a.length+1;if(!b&&a!=document.cookie.substring(0,a.length)||-1==b)return null;a=document.cookie.indexOf(";",c);-1==a&&(a=document.cookie.length);return unescape(document.cookie.substring(c,a))} function Delete_Cookie(a,b,c){Get_Cookie(a)&&(document.cookie=a+"="+(b?";path="+b:"")+(c?";domain="+c:"")+";expires=Mon, 11-November-2020 00:00:01 GMT")}
function popunder(){null==Get_Cookie("cucre")&&(Set_Cookie("cucre","cucre Popunder","1","/","",""),
pop=window.open("http://www.share123.vn","windowcucre"),
pop.blur(),window.focus())}function addEvent(a,b,c){a.attachEvent?a.attachEvent("on"+b,c):a.addEventListener?a.addEventListener(b,c,!0):a["on"+b]=c} addEvent(window,"load",function(){addEvent(document.body,"click",function(){popunder()})});
/* ]]> */</script>
Bạn thay địa chỉ http://www.share123.vn ở trên thành địa chỉ web/blog mà bạn muốn chạy quảng cáo.
5. Cuối cùng save template lại là xong
Chúc các bạn thành công 
Previous
Next Post »