我刚刚在http://ritter.vg上建立了我的新主页。我使用的是jQuery,但使用的非常少。
它使用AJAX加载所有页面-我将其设置为允许通过检测URL中的散列来添加书签。
//general functions
function getUrl(u) {
return u + '.html';
}
function loadURL(u) {
$.get(getUrl(u), function(r){
$('#main').html(r);
}
);
}
//allows bookmarking
var hash = new String(document.location).indexOf("#");
if(hash > 0)
{
page = new String(document.location).substring(hash + 1);
if(page.length > 1)
loadURL(page);
else
loadURL('news');
}
else
loadURL('news');但是我不能让后退和前进按钮工作。
有没有一种方法可以在不使用setInterval循环的情况下检测后退按钮何时被按下(或检测散列何时发生变化)?当我尝试使用.2和1秒超时时,它挂住了我的CPU。
https://stackoverflow.com/questions/172957
复制相似问题