1
我想利用哈希符号在我的AJAX web应用程序中启用后退按钮和刷新功能。jQuery:为什么在这次调用.load()期间IE8没有发送请求?
在Firefox和Chrome浏览器中,当我单击刷新时,浏览器会正确地重新载入所有内容,并在下面的脚本运行时使用#号后面显示的URL发出新的请求。
在IE8中,刷新过程中永远不会发出请求,但会弹出警报,好像它已经弹出一样!
全HTML文件 http://pastebin.com/CVySwtup
示例代码
$(document).ready(function() {
// 1. AJAX history & back button
$(window).bind("hashchange", function (e) {
if (!ignoreHashChange) {
// Load content
$("#content").load(location.hash.substring(1), function() {
alert("content loaded!");
});
}
ignoreHashChange = false;
});
// 2. Home page/refresh action
if (location.hash) {
$(window).trigger("hashchange");
} else {
location.hash = "Customers/List";
}
});
编辑:同在IE8时的行为,我可以,我这里张贴了这个简化的HTML文档中重现此问题使用$ .get()
将随机数字添加到URL中有诀窍。谢谢! – 2011-02-10 03:19:17