HTML是超文本标记语言,是一种专门用来制作网页的语言,而HTML5就是它的第五个版本,2014年10月29日,万维网联盟宣布,经过接近8年的艰苦努力,该标准规范终于制定完成,该标准针对当前互联网的飞速发展制定了更加标准的网页语言规范及适用功能,同时也给我们开发者带来了更多的开发选择,学习它是每个前端开发者必修的课程。
<!DOCTYPE html> <html > <head> <meta charset="UTF-8"> </head> <body> <h1>获得服务器更新</h1> <div id="result"></div> </body> <script type="text/javascript"> if(typeof(EventSource)!=="undefined") { // 您的浏览器支持 Server-Sent var source=new EventSource("/static/example/html5/time_sse.php"); source.onmessage=function(event) { document.getElementById("result").innerHTML+=event.data + "<br />"; }; } else { // 您的浏览器不支持 Server-Sent.. } </script> </html>
<?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); $time = date('Y-m-d H:i:s'); echo "data: The server time is: {$time}\n\n"; flush();执行一下