简体   繁体   English

像facebook聊天的窗口

[英]Window like facebook chat

The Facebook chat window remains open, unchanged, to refresh the page, or even when we change page. Facebook聊天窗口保持打开状态,未更改,以刷新页面,甚至在我们更改页面时。 How to reproduce something similar? 如何重现类似的东西? Tried with frameset, but it did not work. 尝试使用frameset,但它没有用。

How to keep a div open a window similar to the internal, even after refreshing the page or clocar on a website link? 如何保持div打开一个类似于内部的窗口,即使刷新页面或clocar在网站链接后?

Like them, you can try - 喜欢他们,你可以尝试 -

  1. The data is shared between facebook pages. Facebook页面之间共享数据。 Probably HTML5 localStorage ? 可能是HTML5 localStorage Cookies? 饼干? I'm not sure. 我不确定。

  2. If you notice, they don't "refresh" the page, they ajax-refresh the content on the page for subsequent loads. 如果您注意到,他们不会“刷新”页面,他们会刷新页面上的内容以便后续加载。 (unless you manually navigate to the same page, of course.) (当然,除非你手动导航到同一页面。)

  3. Finally, its all CSS mainly some z-index put to use. 最后,它的所有CSS 主要是一些z-index投入使用。

I hope those 3 are enough to get you started. 我希望这3个足以让你入门。

I don't think the whole page of Facebook is loaded. 我认为Facebook的整个页面都没有加载。 Every link has it's own 'target'. 每个链接都有自己的“目标”。 Most of them fetch a page (I think with simply AJAX) to show, others to just change some partials of the screen. 他们中的大多数都会获取一个页面(我想简单地用AJAX)来展示,其他人只是改变一些屏幕的部分内容。 So let's say, you have two divs. 所以说,你有两个div。 One div is the chat-div. 一个div是chat-div。 Positioning fixed and all, z-index on 100, it will always stay on top. 定位固定和全部,z-index在100,它将始终保持在最顶层。 The rest of the page is the other div. 页面的其余部分是另一个div。 Within this div, you can load certain pages with AJAX, without the whole screen to refresh. 在这个div中,您可以使用AJAX加载某些页面,而无需刷新整个屏幕。

As with reloads of the screen: you can easily save (also with AJAX) whether the user closed the chat screen or has it opened. 与重新加载屏幕一样:您可以轻松保存(也使用AJAX)用户是关闭聊天屏幕还是打开它。 Just create a table in a database called 'chats' or something, then when a chatscreen is opened you put an entry in that table with 'person_1', 'person_2' 'lastmessage' and 'active'. 只需在名为“聊天”的数据库中创建一个表,然后在打开一个聊天屏幕时,在该表中放入一个带有'person_1','person_2''lastmessage'和'active'的条目。 When they close the chat, you can put the 'active'-field to false. 当他们关闭聊天时,您可以将“active”字段设置为false。 Then, whenever someone loads the entire website, you check the table chats for active chats, and shows them when there are any. 然后,每当有人加载整个网站时,您检查表格聊天以查看活动聊天,并在有任何内容时显示它们。

I would look into qjuery-qjax: https://github.com/defunkt/jquery-pjax 我会研究qjuery-qjax: https//github.com/defunkt/jquery-pjax

From their docs: 从他们的文档:

pjax works by grabbing html from your server via ajax and replacing the content of a container on your page with the ajax'd html. pjax的工作原理是通过ajax从服务器获取html,并用ajax'd html替换页面上容器的内容。 It then updates the browser's current url using pushState without reloading your page's layout or any resources (js, css), giving the appearance of a fast, full page load. 然后,它使用pushState更新浏览器的当前URL,而无需重新加载页面的布局或任何资源(js,css),从而提供快速,完整页面加载的外观。 But really it's just ajax and pushState. 但实际上它只是ajax和pushState。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM