我使用下面的脚本创建一个弹出窗口。如何在用户点击弹出窗口时隐藏弹出窗口?
if (document.cookie.indexOf('_visited=1') == -1) {
var delay_popup = 1000;
setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup);
var date = new Date;
date.setDate( date.getDate() + 1 ); // текущая дата + 1 день
document.cookie = '_visited=1; path=/; expires=' + date.toUTCString();
}
答案 0 :(得分:0)
您可以像这样添加onclick事件:
if (document.cookie.indexOf('_visited=1') == -1) {
var delay_popup = 1000;
setTimeout("document.getElementById('parent_popup').style.display='block'", delay_popup);
var date = new Date;
date.setDate(date.getDate() + 1); // текущая дата + 1 день
document.cookie = '_visited=1; path=/; expires=' + date.toUTCString();
document.getElementById('parent_popup').onclick = function() {
this.style.display = 'none';
}
}