The dynamic verification code is used in the logon window.
Code:
Corresponding JS
Function refreshcode (){
Document. getelementbyid ("checkcode"). src = "authimg"; (or new date ())
}
Result:
The verification code image in IE 6 can be refreshed, but cannot be refreshed in IE 7 and ff.
Cause:
After analysis, because the SRC specified by JS is the same as the SRC of the original image, the refreshing mechanism of IE 6 is different from that of IE 7 and FF (this page is easily cached by IE, therefore, when you click the verification code image, IE7 and FF only display the cached page to the client, rather than re-going to the server to retrieve the new page), leading to the failure to refresh IE7 and ff.
Solution:
Pass a parameter to the SRC address ("authimg" in the Code) and pass different parameters. The browser considers that the SRC of IMG has changed and then retrieves a new page from the server, instead of reading the cache, a new verification code is generated.
Solution:
You can use the Javascript. Math. Random () function (returns a pseudo-random number between 0 and 1, which may be 0, but always less than 1, [0, 1 )).
Improved code:
Function refreshcode (){
Document. getelementbyid ("checkcode"). src = "authimg? "+ Math. Random ();
}