|  | 
	                
  
    | 
	 
        หน้าต่าง popup อยากให้มันขึ้น 1 ครั้ง ต่อวัน ต้องทำไงครับ     |  
    |  |  
 
              
  
    | 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ใช้ session เก็บค่าเวลาครั้งสุดท้ายที่  popup ไว้ 
 ถ้า เวลาปัจจุบัน มีวันทีเดียวกัน ก็ไม่ต้อง popup
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2018-12-30 12:44:56 | By :
                            Chaidhanan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
 
        
          |  |  |  |  |  
          |  |  | 
            
              | Code (PHP) 
 <?php
session_start();
if(isset($_GET['last_popup'])){
	$_SESSION['last_popup']=date('Y-m-d'); exit;
}
$x=isset($_SESSION['last_popup'])? $_SESSION['last_popup'] : '';
$Popuped = $x == date('Y-m-d');
?>
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>ตัวอย่าง popup </title>
<link rel="stylesheet" href="http://www.jacklmoore.com/colorbox/example1/colorbox.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://www.jacklmoore.com/colorbox/jquery.colorbox.js"></script>
<?php endif;?>
</head>
<body>
<!-- นับเวลาถอยหลัง -->
<input type="text" id="seconds">
</body>
<?php if(!$popuped):?>      
<script>
function openColorBox(){
	$.colorbox({ iframe:true, width:"800px", height:"500px", href: 'images/SE-ED.jpg' });
}
function countDown(){
	seconds--;
	$("#seconds").text(seconds);
	if (seconds === 0){
		openColorBox(); clearInterval(i);
		$.ajax({ url: '?last_popup=1'});
	}
}
var seconds = 1, i = setInterval(countDown, 1000);
</script>
<?php endif;?>
</html>
ปล. ไม่เคยใช้ colorbox
 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2018-12-30 15:08:38 | By :
                            Chaidhanan |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  
 
        
          |  |  |  |  |  
          |  |  | 
            
              | ทำได้หลายวิธีครับ อาจจะใช้พวก localStorage  ของ JavaScript ครับ 
 |  
              | 
                
                  |  |  |  |  
                  |  | 
                      
                        | Date :
                            2019-01-02 10:30:21 | By :
                            mr.win |  |  |  
                  |  |  |  |  |  |  |  
          |  |  |  |  |  |  |