Select Page

// Created fora an Articles on:
// https://www.html5andbeyond.com/session-storage-display-popup-advert/

jQuery(document).ready(function($){

if (sessionStorage.getItem(‘advertOnce’) !== ‘true’) {
$(‘body’).append(‘

‘)
sessionStorage.setItem(‘advertOnce’,’true’);
}

$(‘#advert-once .advert-button’).on(‘click’,function(){
$(‘#advert-once’).hide();
});

$(‘#reset-session’).on(‘click’,function(){
sessionStorage.setItem(‘advertOnce’,”);
});

});

Display Content Only Once Per Session

Refresh Page Only
Reset Session Variable and Refresh Page

body {
background-color: #111;
font-family: ‘Oswald’, sans-serif;
color: #fff;
}

#advert-once {
position: fixed;
bottom: 5px;
right: 5px;
display: inline-block;
background-color: #333;
padding: 5px 5px 0;
z-index: 99999;
}

#advert-once .advert-button {
width: 10px;
height: 10px;
position: absolute;
left: -3px;
top: -3px;
background-color: #ff4500;
border-radius: 5px;
cursor: pointer;
}

#reset-session, #refresh-page {
display: block;
width: 250px;
text-align: center;
font-family: ‘Oswald’, sans-serif;
border-radius: 5px;
border: none;
padding: 2px 5px;
cursor: pointer;
background-color: #ddd;
margin: 5px 0;
}

#reset-session:hover, #refresh-page:hover {
background-color: #f96e5b;
}

Click Here

Close your account?

Your account will be closed and all data will be permanently deleted and cannot be recovered. Are you sure?

Are you sure?

By disagreeing you will no longer have access to our site and will be logged out.

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!