jquery easyui window 的使用跟快取問題
阿新 • • 發佈:2018-12-23
頁面:
<div id="editproject-div-list"></div>
JS程式碼:
$('#editproject-div-list').window({
href:'pmp/project/projects-look.jsp',
title: '檢視專案情況',
maximized:true,
collapsible:false,
minimizable:false,
maximizable:false,
cache : false
});
look.jsp頁面:
當我第二次點選按鈕彈出這個window的時候,它總是去獲取快取的資料。<div id="tt" class="easyui-tabs" > <div title="甘特圖" id="plusdiv"> <iframe name='leftframe' marginwidth=10 marginheight=10 frameborder="no" width='100%' scrolling='no' height=100% src='<%=path %>/pmp/project/Project.html'></iframe> </div> <div title="任務" id="taskdiv"> <iframe name='leftframe' marginwidth=10 marginheight=10 frameborder="no" width='100%' scrolling='no' height=100% src='<%=path %>/pmp/project/projects-taskList.jsp'></iframe> </div> <div title="成果" id=""> <iframe name='leftframe' marginwidth=10 marginheight=10 frameborder="no" width='100%' scrolling='no' height=100% src='<%=path %>/pmp/project/projects-achievement.jsp'></iframe> </div> <div title="編輯專案資訊" id=""> <iframe name='leftframe' marginwidth=10 marginheight=10 frameborder="no" width='100%' scrolling='no' height=100% src='<%=path %>/pmp/project/projects-edit.jsp'></iframe> </div> </div>
cache : false也設定了,為什麼還是走快取呢。於是在js的href屬性中加上了一個時間戳:
href:'pmp/project/projects-look.jsp?date='+getTimeStamp()//取得當前時間 function getTimeStamp() { // 宣告變數。 var d, s; // 建立 Date 物件。 d = new Date(); s = d.getFullYear() + "-"; s += ("0"+(d.getMonth()+1)).slice(-2) + "-"; s += ("0"+d.getDate()).slice(-2) + " "; s += ("0"+d.getHours()).slice(-2) + ":"; s += ("0"+d.getMinutes()).slice(-2) + ":"; s += ("0"+d.getSeconds()).slice(-2) + "."; s += ("00"+d.getMilliseconds()).slice(-3); return s; }
目的是為告訴瀏覽器,不要去獲取本地的快取資料。
但是這樣麼有效果,因為我的look頁面中還有iframe想讓哪個iframe不取快取就在iframe的src中加上時間戳:
<%=path %>/pmp/project/Project.html?date=<%=CommonDate.getDateTime() %>
這樣,就木有快取了!