我不知道从哪里开始,得到修复的可能性可能是1/ 1,000,000,但问题是:我的页面上有一些元素,它们的类为"Edit“或"Add”。它们都有一个名为“编辑”或“添加”的自定义属性,用于传递一个ID。当您单击其中之一时,我使用以下函数打开一个基于上述ID的带有src的iframe的jquery对话框。问题是,假设我在PAGE1上,然后单击EDIT123。然后我转到PAGE2并单击EDIT234。一切正常运转。但是,当我点击back按钮,它会带我回到PAGE1,无论我点击什么,它总是打开EDIT123。奇怪的是,如果设置断点,可以清楚地看到URL和相应的iframesrc是正确的。它总是打开您在PAGE1上单击的最后一件东西,不管它在PAGE1最初加载时或在PAGE2上正确打开了多少东西。
编辑:我忘记提到的,如果你回击,然后点击一个添加按钮,它仍然打开最后一个编辑页面.
<script language="javascript" type="text/javascript">
$(document).ready(function () {
var date = new Date();
//catch a click on an item with the class "edit" open modal div.
$('.Edit').live('click', function () {
var thing = $(this).attr('edit')
var date = new Date();
var url = 'edit/' + thing + '.aspx?appid=' + $('.lblAppID').html() + '&value=' + $(this).attr('entityid') + '&' + date.getTime();
var iframesrc = $('<iframe width="100%" height="100%" marginwidth="0" marginheight="0" frameborder="0" src="' + url + '" scrolling="auto" title="Dialog Title"></iframe>');
$('#modalDiv').dialog("option", "title", "Loading...").empty().append(iframesrc).dialog('open');
return false;
});
//catch a click on an item with the class "add" open modal div.
$('.add').live('click', function () {
var thing = $(this).attr('add')
var url = 'add/' + thing + '.aspx?appid=' + $('.lblAppID').html() + '&' + date.getTime();
var iframesrc = $('<iframe width="100%" height="100%" marginwidth="0" marginheight="0" frameborder="0" src="' + url + '" scrolling="auto" title="Dialog Title"></iframe>');
$('#modalDiv').dialog("option", "title", "Loading...").empty().append(iframesrc).dialog('open');
iframesrc.history.next();
return false;
});
});
</script>
<div id="modalDiv"></div>EDIT2我只是在我的母版页代码背后设置了以下代码来禁用所有缓存。当我单击“后退”时,它会注意到它实际上重新装载了所有的东西.但这个问题仍然存在。*疯狂:
HttpContext.Current.Response.Cache.SetExpires(DateTime.UtcNow.AddDays(-1))
HttpContext.Current.Response.Cache.SetValidUntilExpires(False)
HttpContext.Current.Response.Cache.SetRevalidation(HttpCacheRevalidation.AllCaches)
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache)
HttpContext.Current.Response.Cache.SetNoStore()EDIT3还将其添加到主js文件中。
$(window).bind('unload', function () {
jQuery.cache = {};
alert('clearing cache');
});每次我离开页面,回击或前进时,我都会收到警报。问题仍然存在。
发布于 2011-08-25 14:32:02
我给了iframe一个当前时间戳的ID,现在它运行良好.不知道为什么我会有这么多奇怪的缓存问题。
发布于 2011-08-19 18:57:48
当有AJAX时,我不知道为什么需要一个Iframe,但这听起来像是历史管理问题。
这可能会有所帮助:Current state of Jquery history/back-button plugins?
https://stackoverflow.com/questions/7126066
复制相似问题