• 회원가입
  • 로그인
  • 구글아이디로 로그인

[DOM_Event] JS - message 이벤트 (= onmessage 속성) - 이벤트 메시지 수신 이벤트 (= onmessage이벤트 = 온메시지이벤트) (IE지원 X) ※ 서버센트이벤트

message 예제

 

<h1 id="hz"></h1>

<div id="s_time"></div>


<script>

if(typeof(EventSource) !== "undefined") {

  var source = new EventSource("/server_time.php");

  source.onopen = function() {

    document.getElementById("hz").innerHTML = "홈짱닷컴 (Homzzang.com) 서버갱신시간";

  };

  

  source.onmessage = function(event) {

    document.getElementById("s_time").innerHTML += event.data + "<br>";

  };


} else {

  document.getElementById("s_time").innerHTML = "서버전송이벤트 지원않는 브라우저는 개나 줘버려.";

}

</script>

 


/server_time.php 소스

 

<?php

header('Content-Type: text/event-stream');

header('Cache-Control: no-cache');


$time = date('r');

echo "data: The server time is: {$time}\n\n";

flush();

?>

 

 

 

 

이벤트 소스 통해 메시지 수신 될 때 이벤트 발생.

 

 

 


분류 제목
DOM_Style JS - borderImage 속성 - 테두리이미지 설정/반환 (= borderImage속성 = 보더이미지속…
DOM_Style JS - borderImageOutset -
DOM_Style JS - borderImageRepeat -
DOM_Style JS - borderImageSlice -
DOM_Style JS - borderImageSource -
DOM_Style JS - borderImageWidth -
DOM_Style JS - borderLeft -
DOM_Style JS - borderLeftColor -
DOM_Style JS - borderLeftStyle -
DOM_Style JS - borderLeftWidth -
DOM_Style JS - borderRadius 속성 ★ - 테두리 둥글게 설정/반환 = 둥근 테두리 = 보더레이디어스 속성…
DOM_Style JS - borderRight -
DOM_Style JS - borderRightColor -
DOM_Style JS - borderRightStyle -
DOM_Style JS - borderRightWidth -
DOM_Style JS - borderSpacing 속성 - 테이블의 셀 간 간격 설정/반환 (= borderSpacing속성…
DOM_Style JS - borderStyle 속성 - 테두리스타일
DOM_Style JS - borderTop 속성 - 테두리상단 (= 상단테두리)
DOM_Style JS - borderTopColor -
DOM_Style JS - borderTopLeftRadius -
44/67
목록
찾아주셔서 감사합니다. Since 2012