홈페이지에서 실시간으로 (지정 초마다) 리로드 하는 소스
페이지 정보
작성자 YJNet 작성일13-05-11 02:03 조회9,931회 댓글0건본문
<test1.php>
<script type="text/javascript" src="/js/ajax.js"></script>
<script type="text/javascript" src="/js/prototype.js"></script>
<script>
new Ajax.PeriodicalUpdater("time","test2.php",{frequency:1,decay:1})
</script>
<div id="time"></div>
<test2.php>
<meta http-equiv="content-type" content="text/html; charset=euc-kr">
<?
$time_y = date(Y); // 년
$time_m = date(m); // 월
$time_d = date(d); // 일
$time_h = date(h); // 시
$time_i = date(i); // 분
$time_s = date(s); // 초
echo "지금시각은 ".$time_y."년 ".$time_m."월 ".$time_d."일 ".$time_h."시 ".$time_i."분 ".$time_s."초 입니다.";
?>
<설명>
frequency:1 : 초지정 (1=1초)
test1.php를 실행시키면 test2.php 파일을 불러와서 지정한 초마다 리로드 시킨다.
test1.php를 실행하면 초가 계속바뀌면서 시간이 변경된다.
댓글목록
등록된 댓글이 없습니다.