【发布时间】:2010-04-06 16:13:49
【问题描述】:
我正在使用来自http://www.mikage.to/jquery/jquery_history.html 的 jquery 历史插件。
我无法让插件在 IE8 上运行。在 Firefox 中,它按预期工作。 IE8 在插件创建者的站点上处理示例。
我的网站包含 3 个链接。我首先单击条目 1 到 3。当显示条目 3 时,我点击返回按钮并访问 url http://localhost:5000/de/Playground/HistoryTest#link2。将显示正确的条目。
浏览器的前进按钮不显示,但应该显示。
然后我再次点击后退按钮,但我没有进入条目 1:而是进入条目 3。
有人知道我做错了什么吗?
这是脚本。我用
<script type="text/javascript" >
function callbackHistory(hash) {
if (hash != '') {
if ($.browser.msie) {
// jquery's $.load() function does't work when hash include special characters like aao.
hash = encodeURIComponent(hash);
}
//alert(hash);
$.ajax({
type: "GET",
url: "/de/Playground/HistoryDetail",
data: {
DataKey: hash
},
success: function(htmlSource) {
$("#ajaxContainer").html(htmlSource);
}
});
}
}
$(document).ready(function() {
$.history.init(callbackHistory);
$("a").click(function() {
$.history.load(this.href.replace(/^.*#/, ''));
return false;
});
});
</script>
HMTL
<a href="#link1" rel="history" >link1 </a>
<a href="#link2" rel="history" >link2 </a>
<a href="#link3" rel="history" >link3 </a>
<div id="ajaxContainer" >
</div>
服务器部分仅呈现包含哈希的 HTML sn-p。
<h3>
<%= hash >
</h3>
【问题讨论】:
标签: jquery asp.net-mvc jquery-plugins