验证码图片ie下点换张图片不变ff和谷歌都变解决不了(求助)
index.jsp页面里套了一个iframe iframe src是一个jsp页面,这个jsp页面里调用生成jpg图的代码
可是ie下就是不变还是哪一张图
我用 <meta http-equiv="Expires" CONTENT="0">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
<%
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
out.flush();
%>
之类都不行,求助啊
index.jsp页面里套了一个iframe iframe src是一个jsp页面,这个jsp页面里调用生成jpg图的代码
可是ie下就是不变还是哪一张图
我用 <meta http-equiv="Expires" CONTENT="0">
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<META HTTP-EQUIV="expires" CONTENT="Wed, 26 Feb 1997 08:21:57 GMT">
<%
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
out.flush();
%>
之类都不行,求助啊
<img onclick="this.src='img.jsp?'+Date.parse(new Date())" alt="单击更换" >
<body>
<span>验证码:</span>
<input id="code" style="margin-left: 5px;" size="5" value=""/>
<iframe align="top" frameborder="0"
height="45" width="89" marginheight="0"
marginwidth="0" scrolling="auto" src="imgcode.jsp?code=<%=Math.random() %>" id="ff1">
</iframe>
<a href="javascript:void(0);" onclick="document.getElementById('ff1').src='imgcode.jsp?code=<%=Math.random() %>'">换一张</a>
<input type="button" value="提交" onclick="goTo();"/>
</body>
<%
response.setHeader("Pragma", "no-cache");
response.setHeader("Cache-Control", "no-cache");
response.setDateHeader("Expires", 0);
%>
<%
CreateValidImage c = new CreateValidImage();
String str = c.getContent();
c.creatImage("imgcode.jpg",str,request); //生成验证码图片
%>
<script type="text/javascript">
function codeShow(){
document.getElementById("ii").style.display = 'none';
//alert(111);
//document.write();
document.getElementsByTagName("body")[0].innerHTML = "<img id='codeimg' src='imgcode.jpg' width='80' height='40' title='<%=str.toLowerCase()%>'>"
//alert();
//document.getElementById("codeimg").setAttribute("src","imgcode.jpg");
//alert(222);
}
setTimeout("codeShow();",5000); //延迟5面显示验证码
</script>
<body>
<img id="ii" src="25.gif" width="40" height="40"/>
</body>
下面那个页面就是验证码的页面 通过程序生成一张验证码.然后img显示 上面的页面iframe调用
-----------------------------------------------你不会把验证码存成图片,然后再用 HTML 的 img 去调用吧?这样做完全没有必要的,你可以把这个图片流直接向 response 中输出,并且将 HTTP Content-Type 头改掉,在 img 中访问这个图片流的 JSP 或者 Servlet 的 URL 就可以获得图片了。