如何实现无href的Ajax后退按钮模拟
因此,我的整个网站运行在一个 index.php 页面上,并且根据用户想要执行的操作,通过许多 AJAX 调用动态加载内容。我想使用后退按钮,但目前不能。我读过一些很棒的教程,并搜索了一些与此相关的很棒的 Stackoverflow 问题。我的问题是这样的。我看到的所有教程,包括我倾向于的 Jquery BBQ,似乎在所有教程中都使用了 href
,但我根本不使用锚标记。
我的一个典型功能......就是说加载评论。
$('.comments').live('click', function() {
var id = this.id;
// pass the unique id of the class to a php function, return result
});
我知道我将使用 id
来跟踪网址中的哈希值,但当我找到的只是锚标记示例时,我不确定如何执行此操作。有人可以为我指出一个好的教程的正确方向吗,谢谢!
So my entire site runs off of an index.php page and the content loads dynamically with many AJAX calls depending on what the user wants to do. I want to use the back button but currently I cannot. I have read some great tutorials and scoured over some great Stackoverflow questions regarding this. My problem is this. All the tutorials I'm seeing, including the one I'm leaning to towards, Jquery BBQ, seem to use href
in all the tutorials but I don't use anchor tags at all.
A typical function of mine....to say load a comment.
$('.comments').live('click', function() {
var id = this.id;
// pass the unique id of the class to a php function, return result
});
I know I will use the id
to keep track of the hash in the url, but I'm not sure how to do this when all I'm finding is anchor tag examples. Can someone point me in the right direction of a good tutorial, thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用
window.location
对象的hash
属性:然后,如果用户刷新页面或深层链接到网站:
You can use the
hash
property of thewindow.location
object:And then if a user refreshed the page or deep-links into the site: