I have a notification bar that I only want to display once per session, or possibly not have the notification display for a predetermined amount of time. I am using session storage but unfortunately I cant get it to work correctly.
Thanks
Here is my code ----------->
<script>
$(document).ready(function() {
var $alertdiv = $('<div id = "alertmsg"/>');
$alertdiv.text("Join our email list and receive the latest updates at 3Elements Review.");
$alertdiv.bind('click', function() {
$(this).slideUp(200);
});
$(document.body).append($alertdiv);
$("#alertmsg").fadeIn("slow");
setTimeout(function() { $alertdiv.fadeOut(400) }, 6000);
});
$(window).load(function(){
if(typeof(window.sessionStorage) != 'undefined') {
$("#alertmsg").val(window.sessionStorage.getItem('mySessionVal'));
window.sessionStorage.setItem('mySessionVal', $("#alertmsg").val());
window.sessionStorage.setItem('storedWhen', (new Date()).getTime());
}
});
</script>