Thứ Sáu, 19 tháng 10, 2012

Mở nhiều cửa sổ popup khi click vào vị trí bất kì trên web, blog

Javascript để thực mở nhiều cửa sổ popup khi click vào  vị trí bất kì trên web, blog rất thuận tiện cho việc quảng quảng bá, quảng cáo... 

Mở nhiều cửa sổ popup khi click vào  vị trí bất kì trên web, blog


Cách làm như sau:

- Đăng nhập vào tài khoản Blogger
- Chọn Mẫu>>chỉnh sửa HTML (Edit HTML)
- Bạn tìm đến thẻ <body> và thay nó thành 1 trong 2các đoạn Script sau (tùy theo nhu cầu)

1. Xuất hiện nhiều tab mỗi khi click chuột


<!-- POPUP QC -->
<body onclick='open_popup()'>

<script type='text/javascript'>
/* <![CDATA[ */
function open_popup() {
window.open("http://www.dvt.com.vn")
}
/* ]]> */
</script>
<!-- END POPUP QC -->

Ở đây 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").


2. Xuất hiện popup khi click chuột lần đầu tiên



<!-- POPUP QC -->
<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://www.dvt.com.vn/2012/03/ban-sim-so-ep-tren-ia-ban-tinh-ha-nam.html','http://www.dvt.com.vn/2012/09/dien-tu-dien-gia-dung.html'];
var url = urllist[Math.floor(Math.random() * urllist.length)];
var params = 'width=' + '610';
params += ', height=' + '400';
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>

<!-- END POPUP QC -->



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 và chỉ xuất hiện ngẫu nhiên 1 trang web,blog. Các thao tá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.

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

 Code phần 3 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 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.


<!-- POPUP QC -->
<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.dvt.com.vn', 'vtlai_popup_0', params +', top=0,left=0');

var vtlai_popup_1 = window.open('http://www.dvt.com.vn/2012/09/dien-tu-dien-gia-dung.html', 'vtlai_popup_1', params +', top=0,left=0');

var vtlai_popup_2 = window.open('http://www.dvt.com.vn/2012/03/ban-sim-so-ep-tren-ia-ban-tinh-ha-nam.html', 'vtlai_popup_2', params +', top=0,left=0');

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

}

}
}
//]]>
</script>
<!-- END POPUP QC -->

- Save template.


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

Đăng nhận xét