简体   繁体   中英

showing popup once for each language home page

I want to show popup window once at each language site ( which my site is at double language ) . So when the user open each of them the message shows only one time .. I have used session to do that , but it's only showing one time for both of the language , and i have used this code

    <script>// Created for an Articles on:
// https://www.html5andbeyond.com/session-storage-display-popup-advert/

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

if (sessionStorage.getItem('advertOnce') !== 'true') {
$('body').append('<div id="advert-once"> <div id="boxes"><div style="top: 199.5px; left: 551.5px; display: none;" id="dialog" class="window"><h1 class="dialog">@lang("pagination.poptitle")</h1><h2 class="dialog">@lang("pagination.popup")</h2><button id="clos" class="close  " class="  ">@lang("pagination.popbutton") </button></div></div><div style="width: 1478px; height: 1000px; display: none; opacity: 0.8;" id="mask"></div><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','');
});

});
//# sourceURL=pen.js
</script>

So the question is how to make it shows at each home page language only one time ? It's now show only one time for both of them .

Remember that sessionStorage will be different for each browser tab/window: MDN documentation . I don't quite understand what behavior you actually want or what you're seeing (how does the language change?) but session cookies might be a better choice: How do I create and read a value from cookie?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM