我不知道該從哪裏開始,獲得修復的機率可能是1 000,000,但這裏是問題:我在頁面上有元素的「編輯」或「添加」。他們還有一個自定義屬性,稱爲「編輯」或「添加」,我用它來傳遞一個ID。當你點擊其中的一個時,我使用下面的函數打開一個帶有iframe的jquery-ui對話框,其中的src基於上面提到的ID。問題是,我在PAGE1上,然後點擊EDIT123。然後我去PAGE2然後點擊EDIT234。一切正常。但是,當我按下後退按鈕時,這會將我帶回PAGE1,無論我點擊它,總會打開EDIT123。奇怪的是,如果你設置了斷點,你可以清楚地看到URL和相應的iframesrc是正確的。它始終打開您在PAGE1上單擊的最後一件東西,無論在PAGE1最初加載時或當您在PAGE2上時它正確打開了多少東西。jquery-ui對話框iframe +後退按鈕=災難
編輯:我忘了提,如果你打回來,然後單擊添加按鈕,它仍然會打開最後的編輯頁面...
<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我只設置了下面的代碼在我的母版頁代碼隱藏中禁用所有緩存。當我點擊時,它可以重新加載所有內容......但問題仍然存在。 :batshitcrazy:
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');
});
每次我從一個頁面導航離去,打後退或前進,我得到警報。問題依然存在。
我90%確定這不是歷史問題,因爲iframe正在被清空和重新生成。另外,我在iframe頁面中添加了一行,以便在歷史記錄中返回1,並返回到父頁面。 –
另外,對於它的價值,我有大約30個不同的「編輯」頁面,所以我希望它們自成一體。這就是我選擇使用iframe的原因。它很棒!直到你明顯地回擊... :) –
還要記住,當我設置一個斷點,然後點擊編輯,我可以看到該URL顯然是我單擊的NEW按鈕,但它然後加載陳舊的頁面。 –