To do a registered page today, you need to enter a verification code. Verification code generation is dynamic, but to refresh the page, you can change the verification code, because after the browser will submit a new request to the server, the server will dynamically generate a new verification code response to the browser. To be able to change the verification code without refreshing the page, JavaScript support is required.
The first approach is to take parameters after the request address, which is a small trick. Because the browser accesses the server when the address can be passed along with parameters to the server, and loading content is only to see the address of the following parameters, in addition to , as long as the browser found that the address changes will automatically reload the address to the picture. So just give the address back with the current time parameter then the address is always different, so that the browser think the address changed to reload the captcha image. The specific approach is:In this way, you can automatically change the parameters of the SRC address when the mouse clicks on the image, thus enabling automatic loading.
The second method is to write a JavaScript method, click the link on the call to change the address of the method to achieve automatic change. The specific methods are:
<script type= "Text/javascript" >
function Changeverifycode () {
var img = document.getelementbyidx (' Imgvcode ');//in getting Id=imgvcode object
var time = new Date (). GetTime ();//Get current
img.src = img.src + '? ' + time;//splicing the address of SRC in IMG, with the same purpose as the first method
}
</script>
the place to call is anywhere after.
<a href= "Javascript:verifycode ()" > Can't see clearly? Change the verification code by a different image </a> click ^_^
This is intercepted from the Internet and is for personal collection only.
Two ways of Not refreshing page change verification code in web page