惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
博客园 - 司徒正美
美团技术团队
WordPress大学
WordPress大学
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
人人都是产品经理
人人都是产品经理
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Troy Hunt's Blog
S
Schneier on Security
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
Cisco Talos Blog
Cisco Talos Blog
T
Tor Project blog
B
Blog
NISL@THU
NISL@THU
月光博客
月光博客
博客园 - 【当耐特】
AWS News Blog
AWS News Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
腾讯CDC
L
Lohrmann on Cybersecurity
The Cloudflare Blog
L
LINUX DO - 最新话题
S
Security @ Cisco Blogs
S
Secure Thoughts
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
The Last Watchdog
The Last Watchdog
Project Zero
Project Zero
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Vercel News
Vercel News
H
Hacker News: Front Page
S
SegmentFault 最新的问题
Schneier on Security
Schneier on Security
aimingoo的专栏
aimingoo的专栏
P
Privacy & Cybersecurity Law Blog
博客园 - 三生石上(FineUI控件)
Forbes - Security
Forbes - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
I
InfoQ
T
Tailwind CSS Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
G
GRAHAM CLULEY
W
WeLiveSecurity
小众软件
小众软件
Recorded Future
Recorded Future
Cyberwarzone
Cyberwarzone
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org

博客园 - torome

做开发这么多年,都没有一个自己的站? 我希望四年前就有人告诉我的事情 用php_screw加密PHP代码 gSoap下Server端接口函数的数据传出 gsoap简单实例 原来CASTLE RC2 还不支持IBATIS 1.6,郁闷了很久 硬盘数据恢复原理与方法 用QQWry.Dat作数据源实现IP地址检索 缓存用户控件实例 Forms验证中的roles URL重写 使用csc命令将.cs文件编译成.dll的过程 automation服务器不能创建对象 解决 ASP.NET 中文本框上按回车时系统缺省提交按钮的问题 ASP.NET生成静态HTML页面 sql server 2000 以前的某个程序安装已在安装计算机上创建挂起的文件操作解 马斯若需求层次论 运行VS.net2003出现"找不到一个或多个组件.请重新安装" 人生的35个好习惯
js的comet各个浏览器封装lib
torome · 2011-03-10 · via 博客园 - torome

    SimpleComet是一个轻量级的comet的封装类, 能智能的识别浏览器,应用不同的comet技术,在firefox浏览器上使用ajax,在IE、opera浏览器上使用htmlfile,iframe.

<script type="text/javascript"> // This function will be called every time the server pushes a new event. function push(event) { 	// For this example, we simply show the excuse on the page. 	document.getElementById('excuse').innerHTML = event; }   // This function will be called when/if the stream closes. function disconnected() { 	// For this example we'll just show a nice message. 	document.getElementById('excuse').innerHTML = '<img src="img/arrow.png" alt="" title="" />'+ 		' Click to see MORE reasons why this souldn\'t work!'; 	document.getElementById('control').value = 'start'; }   // This function is executed when the button is clicked. function toggle() { 	// First we check if the stream is open. 	if (!comet.active) { 		// Lets start streaming! 		comet.open('excuses.php', push, disconnected); 		document.getElementById('control').value = 'stop'; 	} else { 		// Streaming is active, means the user wants to stop it. 		comet.close(); 	} } </script>

<!--?php   // First we load the SimpleComet PHP class and the list of excuses. require('inc/simplecomet.class.php'); $comet = new SimpleComet(); $excuses = file('inc/excuses.txt');   // This is an infinite loop, which makes the stream endless. while (true) { 	// We fetch an excuse at random. 	$excuse = trim($excuses[rand(0, count($excuses))]); 	// If the excuse is too long, we get another one. 	if (strlen($excuse) --> 60) { continue; } 	// Finally, we push our excuse to the client. 	$comet->push($excuse); 	// 5 seconds delay before the next excuse. 	sleep(5); }   ?>


simplecomet能监听出链接是否已经断了,是不是很智能,只要负责服务端的输出就行. 
下载: http://www.mandor.net/files/simplecomet-1.0.zip