保持div在页面导航中打开 [英] Keep div open on page navigation

查看:72
本文介绍了保持div在页面导航中打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我下载了一个类似Facebook的聊天应用程序,我对其进行了编辑以适合我的网站,但是在浏览其他页面时保持聊天会话畅通无济.请求.我用此代码进行了试用

i downloaded a facebook-like chat application, i edited it to fit for my website but i'm having problem with keeping the chat session open while navigating other pages.. thanks to all that try to help initially, some suggested AJAX request.. i tried it out with this code

<script type="text/javascript">
function loadXMLDoc()
{
  var xmlhttp;
    if (window.XMLHttpRequest)
    {// code for IE7+, Firefox, Chrome, Opera, Safari
       xmlhttp=new XMLHttpRequest();
    }
    else
    {// code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
       {
          if (xmlhttp.readyState==4 && xmlhttp.status==200)
          {
             document.getElementById("site-body-content").innerHTML=xmlhttp.responseText;
          }
       }
      xmlhttp.open("GET","index.php",true);
  xmlhttp.send();

}

每次创建链接时,我都必须重新编写此函数,以更改其中的名称和页面xmlhttp.open("GET","pagename",true);我现在要做的是为创建的每个页面节省重写功能的压力.

each time i create a link, i'll have to re-write this function changing the name and the page in xmlhttp.open("GET", "pagename", true); what i want to do now is to save the stress of re-writing a function for each page created.

推荐答案

没有"div窗口"之类的东西.

There is no such thing as a 'div window'.

Facebook通过更新栏中的url来做到这一点,但是通过AJAX请求来请求新的页面信息,从而有效地避免了正常浏览.

Facebook does it by updating the url in the bar, but requesting the new page information through an AJAX request, effectively avoiding what would be considered normal navigation.

这篇关于保持div在页面导航中打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆