English 中文(简体)
采用用户流动接口等前线?
原标题:Implementing twitter like user flow interface?

I want to implement twitter like user flow interface, i.e. when user goes to http://twitter.com/#!/abc the page is loaded. I have tried to implement this at:

http://forum.abhibhatia.co.cc/ajax/

What I try to do is that as soon as page loads, the url is splitted by "#!/" and secon part is loaded so that http://forum.abhibhatia.co.cc/ajax/posts.php can be accessed at http://forum.abhibhatia.co.cc/ajax/#!/posts.php . The problem I am facing is that the page does not change after I redirect user using window.location it does not work. I have not tried any other way to redirect users yet. here is the javascript function used:

function geturl(){
    var url=window.location.toString();
    var a=url.split("#!/");
    if(a.length==1)
        a[1]= data.php ;
    return a[1];
    }
function fetchPage(){
    var url=geturl();
    var xmlhttp;
    if (url.length==0&&m==1)
      { url= data.php ;
      return;
      }
    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==1) document.getElementById("data").innerHTML="Loading...";
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        var file=xmlhttp.responseText;//alert(file);
        var contents=file.split("<head>");//alert(contents[0]);
        var useable=contents[1].split("</head>");
        var head=useable[useable.length-2];//alert(head);
        var body=useable[useable.length-1].split("</body>");
        document.getElementById("data").innerHTML=body[0];
        document.head.innerHTML=document.head.innerHTML+head;
        //document.getElementById("data").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET",url,true);
    xmlhttp.send();
}
fetchPage();
最佳回答

更贴近<代码>window. place。 您可以使用窗户。 地点。 然而,正如前面提到的那样,当日,我更倾向于使用第html5号州管理,把标准轮作为退缩。

进一步读:

http://www.adequatelygood.com/2010/7/Saner-HTML5-History-Management

If you really want to make a twitter style interface you should look to put the whole app on a framework which does all of this for you like backbone.js which will mean that you just need to use a REST/CRUD style data source and then will implement all of the state managemet and hash fallbacks for you.

问题回答

暂无回答




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签