Các mã Code POP-UP
16:13Những điểm hay của Code Popup này:
- Xuất hiện 1 lần khi trình duyệt Website mở.
- Cửa sổ trang Website được Pop nhỏ ở góc màn hình -> kéo dài thời gian ở lại của Website được Pop.
...
Code:
<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=50';params+=', height=50';params+=', top=1650, left=1460, resizable=no, scrollbars=yes, location=yes';var w=window.open("http://www.vietmoz.net/",'window1',params).blur();window.focus();}}});});</script>
Thay link bằng link http://www.vietmoz.net/ Website các bạn cần đặt Pop nhé.Trên các nền Website thì đây chỉ là 1 đoạn code javascript nên các bạn dán vào mã <script> là nó hoạt động.
- Hướng dẫn trên Blogspot.
Các bạn vào bảng điều khiển blogger -> bố cục (Layout) -> Thêm 1 tiện ích (Add a Widget) -> HTML/Javascript.
Sau đó dán code trên vào tiện ích vừa thêm và lưu lại là OK.
» Bắt đầu thủ thuật
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://namkna.blogspot.com/")
window.open("http://khuyennong40a.blogspot.com/")
window.open("http://namkna.blogspot.com/2011/05/xem-tivi-truc-tuyen.html")
}
/* ]]> */
</script>
window.open("http://namkna.blogspot.com/")
B. Javascript xuất hiện popup khi click chuột lần đầu tiê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://namkna.blogspot.com/','http://khuyennong40a.blogspot.com/','http://namkna.blogspot.com/2011/12/tuyen-tap-hai-xuan-2012.html'];
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ách khác: Không dùng scripts.
<a expr:href='data:post.url'>
<a expr:href='data:post.url' onclick='window.open("http://namkna.blogspot.com/"); window.open("URL 1"); window.open("URL 2"); window.open("URL 3")'>
5. Lưu mẫu lại và xem kết quả nhaCode Khi Thoát
<script> var exittraffic_splashalertmessage = "Bạn đã xem hết trang web chưa!"; </script>
<script type='text/javascript'>
//<![CDATA[
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
var is_firefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
function DisableExitTraffic() {
PreventExitSplash = true;
}
function addLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
}
else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
}
function addClickEvent(a, i, func) {
if (typeof a[i].onclick != 'function') {
a[i].onclick = func;
}
}
theBody = document.body;
if (!theBody) {
theBody = document.getElementById("body");
if (!theBody) {
theBody = document.getElementsByTagName("body")[0];
}
}
var PreventExitSplash = false;
var LightwindowOpening = false;
function DisplayExitSplash() {
if (PreventExitSplash == false) {
window.scrollTo(0, 0);
if (is_firefox) {
//window.alert(exittraffic_splashalertmessage);
}
PreventExitSplash = true;
if (is_chrome||is_firefox) {
timeout_variable = setTimeout("exittraffic_change_url();", 1000);
} else {
document.location.href = exittraffic_RedirectUrl;
}
return exittraffic_splashalertmessage;
}
}
var a = document.getElementsByTagName('A');
for (var i = 0; i < a.length; i++) {
if (a[i].target !== '_blank') {
addClickEvent(a, i, function() {
PreventExitSplash = true;
});
}
else {
addClickEvent(a, i, function() {
PreventExitSplash = false;
});
}
}
disablelinksfunc = function() {
var a = document.getElementsByTagName('A');
for (var i = 0; i < a.length; i++) {
if (a[i].target !== '_blank') {
addClickEvent(a, i, function() {
PreventExitSplash = true;
});
}
else {
addClickEvent(a, i, function() {
PreventExitSplash = false;
});
}
}
}
addLoadEvent(disablelinksfunc);
disableformsfunc = function() {
// Makes that clicking on the links on the page will not cause this popup to appear
var f = document.getElementsByTagName('form');
for (var i = 0; i < f.length; i++) {
if (!f[i].onclick) {
f[i].onclick = function() {
if (LightwindowOpening == false) {
PreventExitSplash = true;
}
}
}
else if (!f[i].onsubmit) {
f[i].onsubmit = function() {
PreventExitSplash = true;
}
}
}
}
function exittraffic_change_url() {
disable_confirmation = false;
clearTimeout(timeout_variable); // just to make sure
document.location.href=exittraffic_RedirectUrl;
}
addLoadEvent(disableformsfunc);
window.onbeforeunload = DisplayExitSplash;
//]]>
</script>
0 nhận xét