Last active
January 8, 2017 12:21
-
-
Save aminnairi/4b66e7aee5df456b95baee80bd093206 to your computer and use it in GitHub Desktop.
Démonstration image de captcha avec boutton de rechargement en JQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- type de document --> | |
<!doctype html> | |
<!-- dialecte --> | |
<html lang='fr-FR'> | |
<head> | |
<!-- encodage --> | |
<meta charset='utf8'> | |
<title>Captcha avec bouton de rechargement</title> | |
</head> | |
<body> | |
<img src='img/captcha.php' id='captcha' alt='captcha'> | |
<button type='button' id='captchaButton'>Recharger</button> | |
<!-- Framework Javascript --> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> | |
<script> | |
/* lorsque la page a finie de charger */ | |
$(() => { | |
/* lorsque l'utilisateur clique sur le bouton */ | |
$('#captchaButton').click(() => { | |
/* insertion d'une nouvelle image avec une nouvelle date et heure pour ne pas réutiliser celle qui a été mise en cache */ | |
$('#captcha').attr('src', 'img/captcha.php?cache=' + new Date().getTime()); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment