0

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 .

Dina Shaldoum
  • 89
  • 1
  • 4
  • 14
  • well i guess you're doing it right? but you need to check the value of the session if true to that language page or not, if not then popup else not. And array of each pages visited would I guess work, since you've different pages and you just need to push the language inside of that array on every popup so you could have the basis for your checking – Roljhon Mar 12 '17 at 17:30
  • Thank you for your answer , can you tell me how to make that condition for each link of them ? which i'm using {{local}} value to different each one – Dina Shaldoum Mar 13 '17 at 00:37

1 Answers1

0

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?

Community
  • 1
  • 1
Peter Behr
  • 607
  • 1
  • 5
  • 16
  • Thank you for you answer ,I have tried to use cookie , but it wasn't working with me , actually i don't know what was wrong .but even if it's working , i think i will have the same issue , how to diffrrent that both links with diff language – Dina Shaldoum Mar 13 '17 at 00:38