I absolutely can’t figure out how to get the cookie (picture) to fall asleep and then remove it in a couple of seconds. In a clicker cookie, when clicked, the cookies spawn, which then fall down and disappear, something similar is needed.
- 3And in Russian and somehow more fully possible? - Stanislav Belichenko
|
2 answers
If we are talking about the installation and removal of cookies, you can do so. To get started, here is the code for installing and deleting cookies.
Installation:
function set_cookie(name, value, exp_y, exp_m, exp_d, path, domain, secure) { var cookie_string = name + "=" + escape ( value ); if (exp_y) { var expires = new Date ( exp_y, exp_m, exp_d ); cookie_string += "; expires=" + expires.toGMTString(); } if (path) cookie_string += "; path=" + escape ( path ); if (domain) cookie_string += "; domain=" + escape ( domain ); if (secure) cookie_string += "; secure"; document.cookie = cookie_string; } Uninstall:
function delete_cookie(cookie_name) { var cookie_date = new Date ( ); // Текущая дата и время cookie_date.setTime ( cookie_date.getTime() - 1 ); document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString(); } Next, install and delete Cookies in a couple of seconds after installation:
set_cookie(cookie_name, cookie_value) setTimeout(function() { function delete_cookie(cookie_name); }, 2000); |
If we are talking about the "picture", then:
HTML:
<img src="путь_к_картинке" id="#cookie"> CSS:
img { display:none }; Js:
//отображение картинки с id "cookie" document.getElementById("cookie").style.display = "inline-block"; //через 2 секунды (2000 миллисекунд, можно изменить в setTimeout) она пропадет setTimeout(function() { document.getElementById("cookie").style.display = "none" }, 2000); The same code in jQuery:
$("#cookie").show(); setTimeout(function() { $("#cookie").hide(); }, 2000); In general, you need more information .
|