您也可以使用localstorage.要设置存储项目:localStorage.setItem('myPopup','true');
并检查它,您可以执行以下操作:
var poppy = localStorage.getItem('myPopup'); if(!poppy){ function PopUp(){ $('.home-popup').fadeIn(500); } setTimeout(function(){ PopUp(); },1000); // 1000 to load it after 1 second from page load $('.close-popup-btn').click(function() { $('.popup').fadeOut(300); }); localStorage.setItem('myPopup','true'); }