如果按下F5,我想启用Google reCAPTCHA。 我现在有这个代码:
<html>
<head>
<title>HELLO</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
document.onkeydown = fkey;
document.onkeypress = fkey
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
alert("f5 pressed");
// here the Google reCAPTCHA code have to come.
wasPressed = true;
}else {
alert("Window closed");
}
}
</script>
</head>
<body>
<p>If you press F5 you will get a Google reCAPTCHA</p>
</body>
</html>
<div class="g-recaptcha" data-sitekey="6LehRSETAAAAAIl2C3nRFguErdFn02smPN_vtPro"></div>
这是显示Google reCAPTCHA的代码。
我希望有人可以帮助我,所以我可以走得更远。谢谢:D
答案 0 :(得分:0)
<html>
<head>
<title>HELLO</title>
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src='https://www.google.com/recaptcha/api.js'></script>
<script type="text/javascript">
document.onkeydown = fkey;
document.onkeypress = fkey
document.onkeyup = fkey;
var wasPressed = false;
function fkey(e){
e = e || window.event;
if( wasPressed ) return;
if (e.keyCode == 116) {
// here the Google reCAPTCHA code have to come.
$('.g-recaptcha').show();
e.preventDefault();
wasPressed = true;
}else {
alert("Window closed");
}
}
</script>
</head>
<body>
<p>If you press F5 you will get a Google reCAPTCHA</p>
<div class="g-recaptcha" data-sitekey="6LehRSETAAAAAIl2C3nRFguErdFn02smPN_vtPro" style="display:none;"></div>
</body>
</html>