Here a solution without jQuery. Example of functions for Cookie of this reply in Soen and the Domready this other also in Soen. The CSS is from Modal Reveal plugin, but used only for testing and removed all jQuery from the plugin in this example:
<!DOCTYPE html>
<head>
<meta charset="utf-8" />
<title>Popup Demo</title>
<style type="text/css">
/* From http://zurb.com/playground/reveal-modal-plugin */
body {
font-family: "HelveticaNeue","Helvetica-Neue", "Helvetica", "Arial", sans-serif;
}
.texto {
display:block;
margin-top: 100px;
text-align: center;
font-size: 70px;
color: #06f;
}
.reveal-modal-bg {
position: fixed;
height: 100%;
width: 100%;
background: #000;
background: rgba(0,0,0,.8);
z-index: 100;
display: none;
top: 0;
left: 0;
}
.reveal-modal {
visibility: hidden;
top: 100px;
left: 50%;
margin-left: -300px;
width: 520px;
position: absolute;
z-index: 101;
padding: 30px 40px 34px;
}
.reveal-modal .close-reveal-modal {
font-size: 22px;
line-height: .5;
position: absolute;
top: 8px;
right: 11px;
color: #aaa;
text-shadow: 0 -1px 1px rbga(0,0,0,.6);
font-weight: bold;
cursor: pointer;
}
</style>
</head>
<body>
<p class="texto">Conteúdo normal da página</p>
<div id="myModal" class="reveal-modal">
<h1>Exemplo de popup modal</h1>
<p>Ipsum lorem ipsum.</p>
<a class="close-reveal-modal">×</a>
</div>
<script type="text/javascript">
/* From https://stackoverflow.com/a/20604307/1287812 */
function setCookie( name, value, exp_y, exp_m, exp_d )
{
var cookie_string = name + "=" + escape(value);
var expires = new Date(exp_y, exp_m, exp_d);
cookie_string += "; expires=" + expires.toGMTString();
document.cookie = cookie_string;
}
/* From https://stackoverflow.com/a/20604307/1287812 */
function getCookie( cookie_name)
{
var results = document.cookie.match('(^|;) ?' + cookie_name + '=([^;]*)(;|$)');
return results ? unescape(results[2]) : null;
}
/* From https://stackoverflow.com/a/16196548/1287812 */
var execute = function ()
{
if( !getCookie('popup') )
{
document.getElementById('myModal').style.visibility = 'visible';
setCookie('popup', 'visto', 2014, 4, 12);
}
else
console.log('cookie já definido');
};
/* From https://stackoverflow.com/a/16196548/1287812 */
if ( !!(window.addEventListener) )
window.addEventListener("DOMContentLoaded", execute)
else // MSIE
window.attachEvent("onload", execute)
</script>
</body>
</html>
Set an example for the boy ! :)
– Roger Barretto
I imagined something with cookies even. but then, I remembered that cookies is not yet my thing.
– Leandro RR