Hi There,
I’m trying to implement this seemingly simple script to show a 2 second splash screen upon load only once per session.
I can’t figure out what I’m doing wrong. Is there something I’m missing in terms of how jQuery is integrated in Webflow that won’t allow this script to run as is? Syntax error? Am I removing important bits of the script below?
I have a div with an id of splash setup in WF… So, I feel like I have this right but I just can’t seem to get it to work.
<script>
jQuery(document).ready(function($){
if (sessionStorage.getItem('splash') !== 'true') {
$('body').append('<div id="splash"></div>')
sessionStorage.setItem('splash','true');
}
});
</script>
And for comparison… Here is the original script on codepen from the article above… It has a couple of extra bits of code I have removed as they were there simply for “proof of concept” to show the once-per-session functionality, with buttons you could toggle to show that the script actually works.
jQuery(document).ready(function($){
if (sessionStorage.getItem('advertOnce') !== 'true') {
$('body').append('<div id="advert-once"><a href="http://www.html5andbeyond.com/session-storage-display-popup-advert/" target="_blank"><img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/130527/h5ab-logo.png" border="0" alt="banner" /></a><div class="advert-button"></div></div>')
sessionStorage.setItem('advertOnce','true');
}
$('#advert-once .advert-button').on('click',function(){
$('#advert-once').hide();
});
$('#reset-session').on('click',function(){
sessionStorage.setItem('advertOnce','');
});
});
Appreciate any help in advance!!! Thanks for your time.