Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can do this <a href="http://www.quirksmode.org/js/cookies.html" rel="nofollow">using cookies</a>. Go to my <a href="http://jsfiddle.net/UYsFL/1/" rel="nofollow">demo here</a> and you'll see the message, then, if you refresh you wont!</p> <pre class="lang-js prettyprint-override"><code>//check if we've asked them before (in the last 5 minutes) if (!(new RegExp('homeFacebookMessage=true')).test(document.cookie)) { //take a temporary (5min) note that we've asked them document.cookie = 'homeFacebookMessage=true;path=/;max-age=' + 5 * 60 + ';'; //ask them (your code here) alert('Like us on faceface!'); } </code></pre> <p>You could even try some <a href="http://en.wikipedia.org/wiki/Web_storage" rel="nofollow">Web Storage</a>, which will work all the way down to IE8. Here's <a href="http://jsfiddle.net/8DBaT/1/" rel="nofollow">a demo</a>.</p> <pre class="lang-js prettyprint-override"><code>//check if we have asked them already if (!localStorage.getItem('homeFacebookMessage')) { //make a note that we've asked them localStorage.setItem('homeFacebookMessage', 'true'); //ask them (your code here) alert('Like us on faceface!'); } </code></pre> <p>The difference with <code>localStorage</code> is that it's permanent, and won't remind the user to 'like' after 5minutes (when our cookie expires in the first example).<br/> However, if you really like the web storage method you could assign a date/time to <code>homeFacebookMessage</code>, and check how long ago it was instead of simply testing its existence to get the same effect.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload