Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Как сделать чтобы sertimeout срабатывал 1 раз за все время перебывания пользователя (https://javascript.ru/forum/events/38056-kak-sdelat-chtoby-sertimeout-srabatyval-1-raz-za-vse-vremya-perebyvaniya-polzovatelya.html)

Albinos4210 17.05.2013 01:17

Как сделать чтобы sertimeout срабатывал 1 раз за все время перебывания пользователя
 
Как сделать чтобы sertimeout срабатывал 1 раз за все время перебывания пользователя на сайте.
setTimeout(function(){$('#hideCont1').slideToggle('normal')},5000);

cyber 17.05.2013 01:25

Albinos4210, эм, не хочу огорчать но он и так один раз срабатывает..

Albinos4210 17.05.2013 01:59

ТЫ не понял. Есть блок с груп вк фб. Он открывается сам через 5сек. но страниц много и надо чтобы он сработал 1 раз и все.
PS если будет выпрыгивать через 5сек везде то будет вызывать агресию))

cyber 17.05.2013 02:16

Albinos4210, ссылку можно?
блок появляется при каком то действие?
<экстрасенс on>
var performed;
if(peformed) return;

setTimeout(function(){$('#hideCont1').slideToggle('normal')},5000);
peformed = true;

<экстрасенс off>

Albinos4210 17.05.2013 11:11

При клике на ссылку открывается блок
<div class="hideWrap">
<a class="hideBtn" href="javascript://" onclick="$('#hideCont1').slideToggle('normal');return false;">Показать</a>
<div style="display:none;" id="hideCont1" class="hideCont"> Соц сети банер</div>

Zzepish 17.05.2013 12:12

Юзай куки или php+ajax

Albinos4210 17.05.2013 13:05

Цитата:

Сообщение от Zzepish (Сообщение 251050)
Юзай куки или php+ajax

А как сделать на куках?

Albinos4210 17.05.2013 13:29

Я вот что нашел вроди пашет везде кроме хрома

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
  <script>

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom||ie)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}
function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}
function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}
function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
}
function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = ""
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset)
if (end == -1)
end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function dropornot(){
if (get_cookie("droppedin")==""){
window.onload=initbox
document.cookie="droppedin=yes"
}
}
dropornot()
</script>

<div id="dropin" style="position:absolute;visibility:hidden;left:100px;top:100px;width:230px;height:230px;background-color:#EBEBEB"> Здесь находится текст сообщения, картинки и ссылки
</div>
<div><a href="#" onclick="document.getElementById('dropin').style.visibility='visible'" />показать</a></div>
<div><a href="#" onclick="document.getElementById('dropin').style.visibility='hidden'" />скрыть</a></div>

 </BODY>
</HTML>

Deff 17.05.2013 13:34

Цитата:

Сообщение от Albinos4210
А как сделать на куках?

В Инете есть готовый плагин куков для jQuery;
А так - самодельно:
function setcookie(a,b,c) {if(c){var d = new Date();d.setTime(d.getTime()+c);}if(a && b) document.cookie = a+'='+b+';path=/'+(c ? '; expires='+d.toUTCString() : '');else return false;}
 function getcookie(a) {var b = new RegExp(a+'=([^;]){1,}');var c = b.exec(document.cookie);if(c) c = c[0].split('=');else return false;return c[1] ? c[1] : false;}

if(!getcookie('hideCont1')){
  setcookie('hideCont1',true);
  setTimeout(function(){$('#hideCont1').slideToggle('normal')},5000);
}

Albinos4210 17.05.2013 14:10

Цитата:

Сообщение от Deff (Сообщение 251072)
В Инете есть готовый плагин куков для jQuery;
А так - самодельно:
function setcookie(a,b,c) {if(c){var d = new Date();d.setTime(d.getTime()+c);}if(a && b) document.cookie = a+'='+b+';path=/'+(c ? '; expires='+d.toUTCString() : '');else return false;}
 function getcookie(a) {var b = new RegExp(a+'=([^;]){1,}');var c = b.exec(document.cookie);if(c) c = c[0].split('=');else return false;return c[1] ? c[1] : false;}

if(!getcookie('hideCont1')){
  setcookie('hideCont1',true);
  setTimeout(function(){$('#hideCont1').slideToggle('normal')},5000);
}

Чтото не пашит. Куки удалил 0 реакции

http://janko.com.ua/
В нижнем левом углу


Часовой пояс GMT +3, время: 02:03.