01.
<?php
02.
session_start();
03.
if
(isset(
$_GET
[
'last_popup'
])){
04.
$_SESSION
[
'last_popup'
]=
date
(
'Y-m-d'
);
exit
;
05.
}
06.
$x
=isset(
$_SESSION
[
'last_popup'
])?
$_SESSION
[
'last_popup'
] :
''
;
07.
$Popuped
=
$x
==
date
(
'Y-m-d'
);
08.
?>
09.
<!DOCTYPE html>
10.
<html>
11.
<head>
12.
<meta charset=utf-8 />
13.
<title>ตัวอย่าง popup </title>
17.
<?php
endif
;?>
18.
</head>
19.
<body>
20.
<!-- นับเวลาถอยหลัง -->
21.
<input type=
"text"
id=
"seconds"
>
22.
</body>
23.
<?php
if
(!
$popuped
):?>
24.
<script>
25.
function
openColorBox(){
26.
$.colorbox({ iframe:true, width:
"800px"
, height:
"500px"
, href:
'images/SE-ED.jpg'
});
27.
}
28.
function
countDown(){
29.
seconds--;
30.
$(
"#seconds"
).text(seconds);
31.
if
(seconds === 0){
32.
openColorBox(); clearInterval(i);
33.
$.ajax({ url:
'?last_popup=1'
});
34.
}
35.
}
36.
var
seconds = 1, i = setInterval(countDown, 1000);
37.
</script>
38.
<?php
endif
;?>
39.
</html>