使用HTML5和websockets进行协作浏览 [英] Collaborative Browsing using HTML5 and websockets
本文介绍了使用HTML5和websockets进行协作浏览的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想分享我正在浏览的内容以显示在另一个标签上。如何使用HTML5和Websockets实现这一目标?
I want to share whatever I am browsing to appear on another tab. How is it possible to achieve this using HTML5 and Websockets ?
推荐答案
Websockets对此有点矫枉过正。只需将sessionStorage与事件监听器一起使用:
Websockets is a bit overkill for this. Just use sessionStorage with an event listener:
当网址更改时,将网址放入某个会话存储密钥,然后让标签使用以下内容监听更改:
When the url changes, sink the url into some session storage key and then have the tabs listen for changes using something like:
function onStorageEvent(storageEvent){
alert("storage event");
}
window.addEventListener('storage', onStorageEvent, false);
这篇关于使用HTML5和websockets进行协作浏览的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文