so far idea implement function popup("url") checking existing cookie triggered loading body of page (onload - not nice solution know). used exact code here implement cookie functionality included in application.js . there included popup() function:
function popup(startimage) { var x = readcookie('ecocrowd') if (x = 'nopopup') { } else { jquery.slimbox(startimage); } } in html-template start page included following parts:
<body onload="popup("wirdiezukunft.png")"> and
<script>createcookie('ecocrowd','nopopup',7)</script> am missing out? first time working javascript implementation appreciate kind of help. in advance!
update (content of createcookie() ):
function createcookie(name,value,days) { if (days) { var date = new date(); date.settime(date.gettime()+(days*24*60*60*1000)); var expires = "; expires="+date.togmtstring(); } else var expires = ""; document.cookie = name+"="+value+expires+"; path=/"; }
forget cookies, use localstorage has more practical interface, , no weird stuff paths, expirations , domains:
if(!window.localstorage.getitem('hasshown')) { showmypopup(); window.localstorage.setitem('hasshown', true); } there more practical interface cookies in html5 isn't supported localstorage yet.
Comments
Post a Comment