【发布时间】:2011-06-14 16:39:47
【问题描述】:
有什么方法可以监听 url 中的 hashchanges 并记录事件以在 AJAX 等中使用后退按钮。
使用这样的链接:
<a href="/#!page">Go to page!</a>
和这样的脚本:
<script type="text/javascript">
$(function () {
if (window.location.hash){contentload(window.location.hash);}
$('a').click(function() {
fragment = this.hash;
contentload(fragment);
});
});
function contentload(fragment) {
fragment = fragment.slice(1).replace('!', '')
$('#content').load('http://mysite.com/'+fragment+'?ajax=1');
}
</script>
我需要尝试保存页面的状态,我看到了jQuery address plugin,但不知道如何实现它..
【问题讨论】:
-
请不要在标题中写标签。
-
对不起,我从来没有意识到警察在找我
-
请使用“@name:”语法通知其他用户回复。
标签: php javascript jquery hashchange