I'm trying to get a popup to show on load once per session. I'm seeing it okay from my end but my client is saying that he's not seeing it after the first time even after restarting his browser and clearing the cache.
Is there something I should change with the code below? Also, I'm unable to click the close button on mobile with touch. How can I make #popup-close
respond to touch?
HTML
<div id="popup-wrap">
<div id="popup">
<div id="popup-close">×</div>
<a href="http://google.com/" target="_blank">
<img src="image.jpg" width="100">
</a>
<h2>We are featured this month in Architectural Digest!</h2>
<a href="http://www.architecturaldigest.com/" target="_blank">Read the article »</a>
</div>
</div>
JS
if (localStorage.getItem('popState') != 'shown'){
$("#popup-wrap").delay(2000).fadeIn();
localStorage.setItem('popState','shown')
}
$('#popup-close').click(function(e) {
e.preventDefault();
$('#popup-wrap').fadeOut(); // Now the pop up is hidden.
});
CSS
#popup-wrap {
background: #fff;
box-shadow: 1px 0 3px #999;
display: none;
font-family: 'montserrat', sans-serif;
height: 210px;
left: 50%;
margin-left: -250px;
margin-top: -105px;
opacity: .8;
position: absolute;
text-transform: uppercase;
top: 50%;
width: 500px;
z-index: 11;
}
#popup {
padding: 40px;
position: absolute;
}
#popup-close {
cursor: pointer;
font-size: 36px;
position: absolute;
right: 10px;
top: 0;
}
#popup img {
float: left;
margin-right: 20px;
}
#popup h2 {
color: #222;
font-size: 20px;
margin-bottom: .5em;
}
#popup a {
font-size: 12px;
text-decoration: none;
}