사용자 흐름 인터페이스와 같은 트위터를 구현하고 싶습니다. 즉, 사용자가 http://twitter.com/#!/abc
페이지가로드 될 때입니다. 난에서이를 구현하려고 노력 해요 : 내가 뭘하려고하는 것은 바로 페이지가로드, URL에 의해 갈라진다 "#! /"와 SECON 부분은 http://forum.abhibhatia.co.cc/ajax/posts.php
에 액세스 할 수 있도록하는 것이로드이다사용자 흐름 인터페이스와 같은 트위터를 구현하고 있습니까?
http://forum.abhibhatia.co.cc/ajax/
http://forum.abhibhatia.co.cc/ajax/#!/posts.php
. 내가 직면하고있는 문제는 사용자 리디렉션 후 페이지가 변경되지 않는다는 것입니다. window.location
작동하지 않습니다. 아직 다른 방법으로 사용자를 리디렉션하지 않았습니다. 여기에 사용되는 자바 스크립트 함수입니다 : 당신이하면 window.location.hash 사용할 수있는 가까운 window.location
객체에서
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();
부수적으로, hashbangs가 나쁩니다. 나쁜 bad bad *! 대신 html5 기록을 사용해보고 [pjax] (http://pjax.heroku.com/)에서 올바른 방향으로 가리켜 야합니다. –
이유를 설명해 주시겠습니까? –
http://www.quora.com/Are-hashbang-URLs-a-recommended-practice –