Show jQuery popup only at first visit of a page

前端 未结 5 915
盖世英雄少女心
盖世英雄少女心 2020-12-14 20:17

I am new to jQuery, and I have some needs on my website. I want to show the jQuery div popup at the first time only when the user comes. No need to show again and again.

5条回答
  •  时光说笑
    2020-12-14 20:56

    You may use SessionStorage or LocalStorage for this as per your need.

    If you need to do only for that session, use SessionStorage. If it should be stored permanently in the user's browser, use LocalStorage.

        $(document).ready(function(){
            if(sessionstorage && !sessionStorage.getItem('isshow')){
                $('#jPopup').show();
                sessionStorage.setItem('isshow', true);
            }
        });
    

提交回复
热议问题