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();