luojxun,你用过?我照你的办法试了下,但没效果啊,还是被缓存了 代码贴出来你看下: ------------- <html><HEAD> <META HTTP-EQUIV="Pragma" CONTENT="no-cache"> <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache"> <META HTTP-EQUIV="Expires" CONTENT="0"> </HEAD> <script> function showResponse(originalRequest) { //put returned XML in the textarea $('result').innerHTML = originalRequest.responseText; } //////////////////////////////////////////////////// function getObject(objectId) { if(document.getElementById && document.getElementById(objectId)) { // W3C DOM return document.getElementById(objectId); } else if (document.all && document.all(objectId)) { // MSIE 4 DOM return document.all(objectId); } else if (document.layers && document.layers[objectId]) { // NN 4 DOM.. note: this won't find nested layers return document.layers[objectId]; } else { return false; } }var responsecont; var xmlHttp; var contents; var rank_type; var page; function CreateXMLHttpRequest(){ // Initialize Mozilla XMLHttpRequest object if (window.XMLHttpRequest){ xmlHttp = new XMLHttpRequest(); } // Initialize for IE/Windows ActiveX version else if (window.ActiveXObject) { try{ xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e){ try{ xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e){contents = "Loading rquest content fail, Please try it again latter...";} } } }function generatelg(){ var now=new Date(); var hours=now.getHours(); var seconds=now.getSeconds(); var lgname = '015124_fxRzh3XNFfiTtgKN1zxf.gif'; var dstname = 'abc.jpg'; var url = 'generate_logo.php?timespan='+new Date().toString()+'&lg_filename='+lgname+ '&dst_filename=' +dstname+'&scale='+document.fm1.scale.value+'&hmove='+document.fm1.hmove.value+'&vmove='+document.fm1.vmove.value+'&rotate='+document.fm1.rotate.value+'&productmodel=a07090100ux0082'; var loadstatustext="<div>Loading request content, please wait...</div>"; CreateXMLHttpRequest(); getObject('result').innerHTML = loadstatustext; xmlHttp.onreadystatechange = processRequestChange; xmlHttp.open("GET", url, true); xmlHttp.send(null);
}function processRequestChange(){ // only if xmlHttp shows "complete" if (xmlHttp.readyState == 4){ // only http 200 to process if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){ contents= xmlHttp.responseText; //inject centent to tab-pane // alert(contents); showncontents(contents); } } }function showncontents(contents){ responsecont = getObject('result');
我就是想研究一下相同文件名如何刷新图片
Ctrl+F5可以刷新,但是如何在程序中实现呢清除缓存的话好像不可以,
比如下面的代码,加上之后也没刷新图片
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");header("Last-Modified: ".gmdate("D, d M Y H:i:s")." GMT");# HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);# HTTP/1.0
header("Pragma: no-cache");
<HEAD >
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" >
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" >
<META HTTP-EQUIV="Expires" CONTENT="0" >
</HEAD >
上面也是一段相关代码
http://topic.csdn.net/u/20071008/17/1a1a89fa-39a9-409d-8d4f-f472ed55f48f.html
<META HTTP-EQUIV="Pragma" CONTENT="no-cache" >
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache" >
<META HTTP-EQUIV="Expires" CONTENT="0" >
</HEAD >
谁说没用的?有用!你在加上该代码后要先清空一下以前的缓存。
<script language="javascript">
document.write("<img src='abc.gif?" + Math.random() + "'>");
</script>
代码贴出来你看下:
-------------
<html><HEAD>
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="0">
</HEAD> <script>
function showResponse(originalRequest)
{
//put returned XML in the textarea
$('result').innerHTML = originalRequest.responseText;
}
////////////////////////////////////////////////////
function getObject(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
// W3C DOM
return document.getElementById(objectId);
}
else if (document.all && document.all(objectId)) {
// MSIE 4 DOM
return document.all(objectId);
}
else if (document.layers && document.layers[objectId]) {
// NN 4 DOM.. note: this won't find nested layers
return document.layers[objectId];
}
else {
return false;
}
}var responsecont;
var xmlHttp;
var contents;
var rank_type;
var page;
function CreateXMLHttpRequest(){
// Initialize Mozilla XMLHttpRequest object
if (window.XMLHttpRequest){
xmlHttp = new XMLHttpRequest();
}
// Initialize for IE/Windows ActiveX version
else if (window.ActiveXObject) {
try{
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP.3.0");
}
catch (e){
try{
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){contents = "Loading rquest content fail, Please try it again latter...";}
}
}
}function generatelg(){
var now=new Date();
var hours=now.getHours();
var seconds=now.getSeconds();
var lgname = '015124_fxRzh3XNFfiTtgKN1zxf.gif';
var dstname = 'abc.jpg';
var url = 'generate_logo.php?timespan='+new Date().toString()+'&lg_filename='+lgname+ '&dst_filename=' +dstname+'&scale='+document.fm1.scale.value+'&hmove='+document.fm1.hmove.value+'&vmove='+document.fm1.vmove.value+'&rotate='+document.fm1.rotate.value+'&productmodel=a07090100ux0082';
var loadstatustext="<div>Loading request content, please wait...</div>";
CreateXMLHttpRequest();
getObject('result').innerHTML = loadstatustext;
xmlHttp.onreadystatechange = processRequestChange;
xmlHttp.open("GET", url, true);
xmlHttp.send(null);
}function processRequestChange(){
// only if xmlHttp shows "complete"
if (xmlHttp.readyState == 4){
// only http 200 to process
if (window.location.href.indexOf("http")==-1 || xmlHttp.status == 200){
contents= xmlHttp.responseText;
//inject centent to tab-pane
// alert(contents);
showncontents(contents);
}
}
}function showncontents(contents){ responsecont = getObject('result');
responsecont.innerHTML = contents;}</script>
<body>
............//后面的就不贴了啊