Si un bouton peut être cliqué plusieurs fois en peu de temps, il peut être cliqué de manière malveillante pour l'utilisateur.
Le code est le suivant:
La copie de code est la suivante:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<Title> JS Timed Event </Title>
<script src = "js / jquery-1.9.1.js" type = "text / javascript"> </ script>
</ head>
<body>
<form id = "form1" runat = "server">
<div>
<input type = "bouton" value = "cliquez moi" id = "btn" onclick = "show ()" />
</div>
<script type = "text / javascript">
/ *
TimeId = Window.SetTimeout ("Method ()", 1000);
TimeId = Window.SetInterval ("Method ()", 1000);
* /
var nn = 30;
var tipid;
fonction show () {
TipId = Window.SetInterval ("start ()", 1000);
}
fonction start () {
if (nn> 0) {
var vv = "cliquez sur moi (" + nn + ")";
$ ("# btn"). att ("Disabled", "Disabled");
$ ("# btn"). att ("valeur", vv);
nn--;
} autre {
nn = 30;
$ ("# btn"). Removeattr ("Désable");
$ ("# btn"). att ("valeur", "cliquez sur moi");
Window.ClearInterval (Tipid);
}
}
</cript>
</ form>
</docy>
</html>