用户工具

站点工具


html:javascript:example:taobao-pop-window

淘宝弹窗代码 Javascript

$E.on(window, 'load', function() {
if (TB.bom.getCookie('_tb_defaultbackpop_') == 1) return;
var saveStatus = function() {
       var nowDate = new Date();
       var nowTime = nowDate.getHours()*3600 + nowDate.getMinutes()*60 + nowDate.getSeconds();
       var DAY = 24*3600;
       var leaveTime = DAY - nowTime;
TB.bom.setCookie('_tb_defaultbackpop_', 1, leaveTime/DAY, document.domain, '/');
}
var createPopup = function() {
       var adPopup = window.open('about:blank','_backad','width='+(pw||760)+',height='+(ph||480)+',toolbar=no,location=no,directories=no,status=yes,resizable=no,scrollbars=no');
adPopup.blur();
adPopup.opener.focus();
adPopup.location = adUrl;
}
var popAd = function() {
       try {
         createPopup();
       } catch (e) {
         $E.on(document, 'click', popAd2);
       } finally {
saveStatus();
}
}
var popAd2 = function() {
       $E.removeListener(document, 'click', arguments.callee);
       try {
         createPopup();
       } catch (e) {}
saveStatus();
}
 
var adUrl = 'http://www.taobao.com/promotion/defaultbackpop.html';
var pw = '760', ph = '480';
 
setTimeout(popAd, 2000);
});
html/javascript/example/taobao-pop-window.txt · 最后更改: 2010/06/02 01:18 (外部编辑)